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

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.

Related

Encountering problems with flutter when building for archive

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

Error: /usr/bin/codesign exited with code 1 when try to archive xamarin.ios app

i have xamarin forms project work fine in debug when try to archive xamarin ios to generate ipa with valid certificate.
i tried build & clean & rebuild & restart visual studio and restart mac device more time with no solution also tried to delete certificate inside keychain and download certificate again but not resolved each time try to build project give me these two errors:
Error: /usr/bin/codesign exited with code 1
*Error: Failed to codesign 'bin/iPhone/Release/CustomerApp.iOS.app': Warning: unable to build chain to self-signed root for signer "iPhone Distribution: CerificateName"
any one can help
thanks.

Xcode build error "Command /usr/bin/codesign failed with exit code 1" in simulator and real environment

I recently created a new project. It was 8 months ago when I created the project last time. So, when I built a new project with simulator, I got an error like the following.
CodeSign {app directory}
cd {app directory}
export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
Signing Identity: "-"
/usr/bin/codesign --force --sign - --entitlements /Users/{username}/Library/Developer/Xcode/DerivedData/{app directory}
/Users/{username}/Library/Developer/Xcode/DerivedData/{app directory}/{app name}: Is a directory
Command /usr/bin/codesign failed with exit code 1
I tried
Confirm Xcode sign-in status
Check Automatically manage signing
Clean up and delete build DerivedData
Reboot Xcode and PC
Reinstall Podfile and cocoapod
Recreate certificate
xattr -c
I tried several method. But it did not solve it.
Most people seem to be OK in a simulation environment, but in my case it is not. Both the real environment and the simulation will not work.
Thank you.
The error is there in the output from the command:
/Users/{username}/Library/Developer/Xcode/DerivedData/{app directory}/{app name}: Is a directory
You most likely have some custom build phase or script phase which is stomping over your app's executable with a directory.

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 :)

Xcode 5 continuous integration CodeSign fail

Hi there.
I'm trying to configure continuous integration for my iOS app with xcode 5 and OS X Server. I added certificates and p12 to system KeyChain, I also copied provisioning profiles to server folder for profiles.
Integration fails and log shows error message
Short message:
Command /usr/bin/codesign failed with exit code 1
Full message:
CodeSign
/Library/Server/Xcode/Data/BotRuns/Cache/c60acccd-d128-d128-b0e3-070a65bdd9dc/DerivedData/Build/Intermediates/ArchiveIntermediates/MomentSeller/InstallationBuildProductsLocation/Applications/MomentSeller.app
cd /Library/Server/Xcode/Data/BotRuns/Cache/c60acccd-d128-d128-b0e3-070a65bdd9dc/source/Moment
setenv CODESIGN_ALLOCATE /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
setenv 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"
Using code signing identity "iPhone Distribution: Company Name. (ZX6C5SJYP9)" and provisioning profile "Moment Seller Production"
(E6FC8157-98F3-4A28-BFF3-36EFA6334019)
codesign --force --sign C2F81E886780437B90630A748111D3340DC8EFC8 --resource-rules=/Library/Server/Xcode/Data/BotRuns/Cache/c60acccd-d128-d128-b0e3-070a65bdd9dc/DerivedData/Build/Intermediates/ArchiveIntermediates/MomentSeller/InstallationBuildProductsLocation/Applications/MomentSeller.app/ResourceRules.plist
--entitlements /Library/Server/Xcode/Data/BotRuns/Cache/c60acccd-d128-d128-b0e3-070a65bdd9dc/DerivedData/Build/Intermediates/ArchiveIntermediates/MomentSeller/IntermediateBuildFilesPath/Moment.build/Release-iphoneos/MomentSeller.build/MomentSeller.xcent
/Library/Server/Xcode/Data/BotRuns/Cache/c60acccd-d128-d128-b0e3-070a65bdd9dc/DerivedData/Build/Intermediates/ArchiveIntermediates/MomentSeller/InstallationBuildProductsLocation/Applications/MomentSeller.app
/Library/Server/Xcode/Data/BotRuns/Cache/c60acccd-d128-d128-b0e3-070a65bdd9dc/DerivedData/Build/Intermediates/ArchiveIntermediates/MomentSeller/InstallationBuildProductsLocation/Applications/MomentSeller.app:
User interaction is not allowed. Command /usr/bin/codesign failed with
exit code 1
** ARCHIVE FAILED **
The following build commands failed: CodeSign
/Library/Server/Xcode/Data/BotRuns/Cache/c60acccd-d128-d128-b0e3-070a65bdd9dc/DerivedData/Build/Intermediates/ArchiveIntermediates/MomentSeller/InstallationBuildProductsLocation/Applications/MomentSeller.app
(1 failure)
Any ideas?
Thanks.
I've run into this problem myself. This blog helped me out. http://matt.vlasach.com/xcode-bots-hosted-git-repositories-and-automated-testflight-builds/
As posted by Dominik Kroutvar:
User interaction is not allowed. Command /usr/bin/codesign failed with
exit code 1
This error happens when the following setting is not made manually. As
described in one of the posts above you have to put the mobileprofile
for code signing in the system keychain. The certificate is called
iPhone Distribution:. This distribution certificate must have a
private key! Open the Settings dialog either by double click on the
private key or through the context menu>Get Info. Then go to Access
control and put /usr/bin/codesign in the table. This allows the
codesign application to sign your built application. After that
everything should work without the meaningless codesign error exit
code 1.
As already stated you simply need to run security -v unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN".
Run this before the build and the codesign succeeds.

Resources