Encountering problems with flutter when building for archive - ios

I have been getting this frustrating error while building my flutter app for archive even after it runs well on simulator and builds sucessfully. I want to build for archive and send to the store but i keep getting this code signing error.
I have done lots of things like;
Toggling keychain login on and off.
Deleted derived data
Deintegrated pods and reinstalled
Regenerated machine certificates
And what is more frustrating is that it happens on this one project alone.
Logs
CodeSign /Users/User/Library/Developer/Xcode/DerivedData/Runner-ayrwpftzqolnkoekbffcnpggwwxu/Build/Intermediates.noindex/ArchiveIntermediates/Runner/InstallationBuildProductsLocation/Applications/Runner.app (in target 'Runner' from project 'Runner')
cd /Users/User/FlutterProjects/heala_doctor_app/ios
export CODESIGN_ALLOCATE\=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
Signing Identity: "Appl"
Provisioning Profile: "iOS Team Provisioning Profile: com.heala.doctor"
(f)
/usr/bin/codesign --force --sign --entitlements /Users/User/Library/Developer/Xcode/DerivedData/Runner-ayrwpftzqolnkoekbffcnpggwwxu/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Runner.build/Release-iphoneos/Runner.build/Runner.app.xcent --generate-entitlement-der /Users/User/Library/Developer/Xcode/DerivedData/Runner-ayrwpftzqolnkoekbffcnpggwwxu/Build/Intermediates.noindex/ArchiveIntermediates/Runner/InstallationBuildProductsLocation/Applications/Runner.app
/Users/User/Library/Developer/Xcode/DerivedData/Runner-ayrwpftzqolnkoekbffcnpggwwxu/Build/Intermediates.noindex/ArchiveIntermediates/Runner/InstallationBuildProductsLocation/Applications/Runner.app: the code cannot be read by the verifier (file system permissions etc.)
Command CodeSign failed with a nonzero exit code

Related

IOS App Build issue: Command CodeSign failed with a nonzero exit code

I am trying to build my IOS app (developed using capacitor and ionic frameworks).
Just after integrating Google Firebase and adding Resources/GoogleService-Info.plist file I am having followng error while building my app in XCode.
Command CodeSign failed with a nonzero exit code
CodeSign /Users/piyush/Library/Developer/Xcode/DerivedData/App-cfgpruswvcmgvpcxuzeyccwfgdyx/Build/Products/Debug-iphonesimulator/App.app (in target 'App' from project 'App')
cd /Users/piyush/Downloads/ncsmobileapp/ios/App
export CODESIGN_ALLOCATE\=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
Signing Identity: "-"
/usr/bin/codesign --force --sign - --entitlements /Users/piyush/Library/Developer/Xcode/DerivedData/App-cfgpruswvcmgvpcxuzeyccwfgdyx/Build/Intermediates.noindex/App.build/Debug-iphonesimulator/App.build/App.app.xcent --timestamp\=none --generate-entitlement-der /Users/piyush/Library/Developer/Xcode/DerivedData/App-cfgpruswvcmgvpcxuzeyccwfgdyx/Build/Products/Debug-iphonesimulator/App.app
/Users/piyush/Library/Developer/Xcode/DerivedData/App-cfgpruswvcmgvpcxuzeyccwfgdyx/Build/Products/Debug-iphonesimulator/App.app: code object is not signed at all
In subcomponent: /Users/piyush/Library/Developer/Xcode/DerivedData/App-cfgpruswvcmgvpcxuzeyccwfgdyx/Build/Products/Debug-iphonesimulator/App.app/AppIcon60x60#2x.png
Command CodeSign failed with a nonzero exit code
I tried cleaning the build cahce, restarting the xcode.
re-building the app through capacitor, but nothig solved this issue yet.
Can anyone help in solving this issue?
Update
While archiving the app following error occurs:
CodeSign /Users/piyush/Library/Developer/Xcode/DerivedData/App-cfgpruswvcmgvpcxuzeyccwfgdyx/Build/Intermediates.noindex/ArchiveIntermediates/App/InstallationBuildProductsLocation/Applications/App.app (in target 'App' from project 'App')
cd /Users/piyush/Downloads/ncsmobileapp/ios/App
export CODESIGN_ALLOCATE\=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
Signing Identity: "Apple Development: Piyush Aggarwal (ZWHGYV6A62)"
Provisioning Profile: "iOS Team Provisioning Profile: app.neo.school"
(d2353688-03d7-47ff-942f-4f34fd4c6a93)
/usr/bin/codesign --force --sign 5FE6CDFE4B615D56B70C5DAEB7A151005A1122AE --entitlements /Users/piyush/Library/Developer/Xcode/DerivedData/App-cfgpruswvcmgvpcxuzeyccwfgdyx/Build/Intermediates.noindex/ArchiveIntermediates/App/IntermediateBuildFilesPath/App.build/Release-iphoneos/App.build/App.app.xcent --generate-entitlement-der /Users/piyush/Library/Developer/Xcode/DerivedData/App-cfgpruswvcmgvpcxuzeyccwfgdyx/Build/Intermediates.noindex/ArchiveIntermediates/App/InstallationBuildProductsLocation/Applications/App.app
/Users/piyush/Library/Developer/Xcode/DerivedData/App-cfgpruswvcmgvpcxuzeyccwfgdyx/Build/Intermediates.noindex/ArchiveIntermediates/App/InstallationBuildProductsLocation/Applications/App.app: code object is not signed at all
In subcomponent: /Users/piyush/Library/Developer/Xcode/DerivedData/App-cfgpruswvcmgvpcxuzeyccwfgdyx/Build/Intermediates.noindex/ArchiveIntermediates/App/InstallationBuildProductsLocation/Applications/App.app/AppIcon60x60#2x.png
Command CodeSign failed with a nonzero exit code
Please try to delete the derived data and clean the build.
Steps to delete derived data:-
1.Open your project,Go to files -> Workspace Settings
Then you will find a derived data location with an arrow:-
Just click on that arrow,after that you will find a folder named derived data,
delete all the files inside derived data folder.
Then it will working fine.
The issue was due to resources folder.
I created that folder to add my GoogleServices-Info.plist file.
I renamed my resources folder and changaed the path to my GoogleServices-Info.pllist file by following code in build phrases of the app in xcode:
PATH_TO_GOOGLE_PLISTS="${PROJECT_DIR}/App/[FOLDER NAME]"
cp -r "$PATH_TO_GOOGLE_PLISTS/GoogleService-Info.plist" "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/GoogleService-Info.plist" ;
I have the same (random) issue when Archiving project where OneSignal (specifically OneSignalNotificationServiceExtension) framework is included. What I have to do to make it work (w00t) is to change KeyChain Trust setting on Apple Worldwide Developer Relations Certification Authority (Expires: Tuesday, 7 February 2023 at 22:48:47 Central European ) certificate back to Use System Defaults and then again back to Always Trust. I have no idea why this works, but it works.

No matching provisioning profiles found - NativeScript iOS deploy

I want to publish an update of my NativeScript app into AppStore. Until yesterday the following steps worked:
move into app directory (from Terminal)
execute tns publish ios
enter valid e-mail & password combination
Now I need to do another update, but I keep getting the following error:
=== BUILD TARGET HandyApp OF PROJECT HandyApp WITH CONFIGURATION Release ===
Check dependencies
Code Sign error: No matching provisioning profiles found: No provisioning profiles matching an applicable signing identity were found.
** ARCHIVE FAILED **
The following build commands failed:
Check dependencies
(1 failure)
Command xcodebuild failed with exit code 65
# publish ios
I am working under Xcode 7.3. I checked my iPhone Developer certificate in Xcode and in my keychain, it is active and not expired. The Provisioning Profile is shown in Xcode. I ensured to use the certificate that is saved in apple.developer.com (by downloading it and replacing the old one in that directory).
I got:
my .mobileprovision
my .cer
my .p12
everything in the same directory.
Still there seems something not to be matching. I just can't figure out what might be running wrong. Does anyone know what else I could try to get it working?

Xcode 8 Fastlane build with TeamCity codesign failed with exit code 1

I've got a weird serious problem with Xcode 8.3.2 on macOS Sierra. I could build the app locally on build machine with fastlane or manually executing commands. Both development and ad-hoc build can be created locally.
$ fastlane <lane_name>
But when tried the same from TeamCity it throws following error.
[exec]/usr/bin/codesign --force --sign 5609CEE02FBF256EDBF60DB28C1A2995A2153B5B --entitlements /Users/<username>/Library/Developer/Xcode/DerivedData/<AppName>-frpvxgdtafatrrgbjqbbepgfzvak/Build/Intermediates/ArchiveIntermediates/SabaMeeting/IntermediateBuildFilesPath/<AppName>.build/Release-iphoneos/<AppName>.build/<AppName>.app.xcent --timestamp=none /Users/<username>/Library/Developer/Xcode/DerivedData/<AppName>-frpvxgdtafatrrgbjqbbepgfzvak/Build/Intermediates/ArchiveIntermediates/SabaMeeting/InstallationBuildProductsLocation/Applications/<AppName>.app
[exec] /Users/<username>/Library/Developer/Xcode/DerivedData/SabaMeeting-frpvxgdtafatrrgbjqbbepgfzvak/Build/Intermediates/ArchiveIntermediates/SabaMeeting/InstallationBuildProductsLocation/Applications/<AppName>.app: unknown error -1=ffffffffffffffff
[exec] Command /usr/bin/codesign failed with exit code 1
[exec]
[exec] ** ARCHIVE FAILED **
[exec]
[exec]
[exec] The following build commands failed:
[exec] CodeSign /Users/<username>/Library/Developer/Xcode/DerivedData/SabaMeeting-frpvxgdtafatrrgbjqbbepgfzvak/Build/Intermediates/ArchiveIntermediates/<AppName>/InstallationBuildProductsLocation/Applications/SabaMeeting.app
[exec] (1 failure)
TeamCity pulls the code and even executes the commands but fails.
Build Step: Command Line is set TeamCity with a custom script.
Tried following ways but not working:
Xcode Preferences ->Accounts->Delete already added account and add it again
Generated new Distribution and Developer Certificate and installed in KeyChain. New Provisioning Profiles and installed in Xcode.
Verified keychain access to private keys by "Allow all applications to access this item". Moved Certificates from login to System with access control to all.
Reinstalled xcode 8.3.2, restarted the machine.
Apple Worldwide Developer Relations Certificate Authority is installed.
Verified resource fork, finder information, or similar detritus not allowed in the app and derived data directory. https://developer.apple.com/library/content/qa/qa1940/_index.html
The project doesn't use CocoaPods.
Tried clearing DerivedData.
Any many more r&d. Any help will be appreciated.
How does your lane look like on your fastfile? Please share it...
My guess;
3 Verified keychain access to private keys by "Allow all applications to access this item". Moved Certificates from login to System with access control to all.
Teamcity is probably not accessing to your certificates and failing.
Try this;
Move certificates back to login from system.
Add following before your gym or whatever fastlane command is building the .ipa. This will let teamcity unlock and access to keychain.
lane :beta do |options|
unlock_keychain(path:"login.keychain", password:"yoursystempassword")
sh "security set-keychain-settings -t 3600 -l ~/Library/Keychains/login.keychain"
gym(scheme: "yourapp", workspace:"probably you dont have a wokrspace so no need")
end

XCode code siging error XCTest

When I try to run my application on a simulator, everything works fine. But when I try to build it to test it on a real device, I get the following error:
CodeSign /Users/fvoordeckers/Library/Developer/Xcode/DerivedData/MyProject-##########/Build/Products/Debug-iphoneos/MyProject.xctest
cd /Users/fvoordeckers/Documents/Projecten/MyProject/iOS
export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
Signing Identity: "iPhone Developer: Frederik (########)"
/usr/bin/codesign --force --sign ##################/Users/fvoordeckers/Library/Developer/Xcode/DerivedData/MyProject-##########/Build/Products/Debug-iphoneos/MyProject.xctest
/Users/fvoordeckers/Library/Developer/Xcode/DerivedData/MyProject-##########/Build/Products/Debug-iphoneos/MyProject.xctest: bundle format unrecognized, invalid, or unsuitable
Command /usr/bin/codesign failed with exit code 1
I've changed IDs with #. I created a provisioning profile that includes the device I'm using and al the required certificates. It doesn't seem to have a problem with the app but with the xctest... I also tried adding the '--deep' flag to the signing configuration but it didn't help...
Go to Edit Scheme in xcode -> In Build Target -> Remove MyProject.xctest completely or uncheck all the boxes of MyProject.xctest Analyze , Test etc..
Clean your project and then Run on the device.
I had the very same issue and nothing helped (updating the schemes, changing the provisioning profiles or code signing identity, etc.) except updating Xcode to its latest beta version: Xcode 7.3 Beta 4.
I guess Apple did some major improvements in this new version :)

building xcode project from jenkins fails. when building in command line runs just fine. why?

building xcode project from jenkins fails.
when building in command line runs just fine.
why?
this is is the error I get:
[BEROR]Code Sign error: No matching provisioning profile found: Your build settings specify a provisioning profile with the UUID “_UUID_”, however, no such provisioning profile was found.
[BEROR]CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 7.1'
this is the command line used:
xcodebuild -project PROJECTNAME.xcodeproj/ -target TARGETNAME -configuration Release -sdk iphoneos7.1 clean build
ps: anything with OBJECT was censored so this question can appear online, there was real data there before.
Are you using the login key-chain or did you create a different key-chain for jenkins builds app signing?
If you are just using the login key-chain make sure you unlock the key-chain during the build.
If you are using a different key-chain make sure you swap key-chains and then unlock it.
Jenkins - Xcode build works codesign fails - this thread is quite informative.
Also adding these 2 commands to your build can help you debug it:
/usr/bin/security list-keychains
/usr/bin/security find-identity

Resources