Codesign failed with exit code 1 - failing to build copy resources - ios

I realise that this question has been asked quite a few times already, but I have tried to solve using a lot of the given answers with no luck.
CodeSign /Users/XXXXXXXX/Library/Developer/Xcode/DerivedData/XXXXXXXX-blligpejpeysabczydnolvooizok/Build/Products/Debug-iphoneos/XXXXXXXX.app
cd /Users/XXXXXXXX/Documents/Development/Native/tomhais
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/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
Signing Identity: "iPhone Developer: XXXXXXX"
Provisioning Profile: "iOS Team Provisioning Profile: XXXXXX"
XXXXXXXX
/usr/bin/codesign --force --sign XXXXXXXXX --entitlements /Users/XXXXXXX/Library/Developer/Xcode/DerivedData/XXXXXXX-XXXXXXXX/Build/Intermediates/tomhais.build/Debug-iphoneos/XXXXXX.build/XXXXXXX.app.xcent --timestamp=none /Users/XXXXXXX/Library/Developer/Xcode/DerivedData/XXXXXXX-XXXXXXXX/Build/Products/Debug-iphoneos/tomhais.app
/Users/XXXXXXX/Library/Developer/Xcode/DerivedData/XXXXXXX-XXXXXXXX/Build/Products/Debug-iphoneos/XXXXXXXX.app: code object is not signed at all
In subcomponent: /Users/XXXXXXXX/Library/Developer/Xcode/DerivedData/XXXXXXXX-XXXXXXXX/Build/Products/Debug-iphoneos/XXXXXXXX.app/0CeadLitir.png
Command /usr/bin/codesign failed with exit code 1
I have tried the following:
Deleted my developer account and added it again
Deleted all the provisioning profiles and re-downloaded them
Checked the key-chain access to make sure that they use system
defaults
Checked that my Code Signing is pulling in the right
certificates
Deleted the image from resources/ removed it from `Build Phases / Copy Bundle Resources and added it again'
Rebooted the machine
Cursed at the machine
Any further ideas of what I might try?

What I found was that having a folder named "resources" in the application bundle will cause code sign to fail. This seems to be an undocumented consequence of some implementation detail of iOS apps or code signing, I think. An empty project with just a resources folder with one random file in it reproduced the issue.
I couldn't easily rename the folder with our shared codebase so my solution was to put my "resources" folder in a parent folder with a different name, and adjust the way our resource path was built.

I had the same problem, what resolved it was lock/unlock keychain login as described here: link

First, check your code have lots of useless variables and remove them, then then x code top bar product -> clear and build the folder and run

I had the same problem and spent about a day by trying all suggestions.
Finally, I have solved the problem.
Close Xcode.
Open "Keychain Access.app", find and remove all "Apple Worldwide Developer Relations Certification Authority".
Login to developer.apple.com and remove development and distribution certificate.
Open Xcode again and check "Automatically manage signing". Then Xcode(should be 11.4.1 or later) will download renewed WWDR certificate automatically and generate development certificate.
Clean project and build.

I was working with the ARKit, and the problem appears when I try to convert a .dae element into a .scn after that I try to compile but the non zero exit error appears.
I try everything above but nothing worked for me. But I notice that in the project inside the art.scnassets folder was my new file but without the .snc extension.
So the solution was very simple, I just add the .snc to my file, I Clean My Build Folder from the Product menu in Xcode, I ran it again and that Works for me.

Related

Command /usr/bin/codesign failed with exit code 5

I have recently made the update of mac OS from 10.11 to 10.12 and i can't signing my iOS applications in Xcode 8.0 anymore.
I get this error :
CodeSign /Users/aymericpitre/Library/Developer/Xcode/DerivedData/OrpiDirect-ghphwnhfbtdulhgauptikzmsrqdi/Build/Products/Debug-iphoneos/OrpiDirect.app
cd /Users/aymericpitre/Documents/projets/Ville-de-lyon-iPhone/VilleDelyon_git/ville_de_lyon
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/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
Signing Identity: "iPhone Developer: aymeric xxxx (SYC4JR6K8G)"
Provisioning Profile: "VDL-sierra"
(756b4f3a-26aa-4937-ba40-4cc4eea03e92)
/usr/bin/codesign --force --sign D60599B3AE74EE1D4863C249026FA28545A07689 --entitlements /Users/aymeric/Library/Developer/Xcode/DerivedData/OrpiDirect-ghphwnhfbtdulhgauptikzmsrqdi/Build/Intermediates/OrpiDirect.build/Debug-iphoneos/OrpiDirect.build/OrpiDirect.app.xcent --timestamp=none /Users/aymeric/Library/Developer/Xcode/DerivedData/OrpiDirect-ghphwnhfbtdulhgauptikzmsrqdi/Build/Products/Debug-iphoneos/OrpiDirect.app
Command /usr/bin/codesign failed with exit code 5
The provisioning profile seems to be ok because i find it in the Xcode/preferences/accounts window.
I've tried to run xattr -c * command inside derived folder but it doesn't work.
I finally make it work. After digging into the internal logs, I realized that the problem came from the keychain. I tried to delete all the entries with the GUI, but one couldn't be deleted (named "1")
So I had to delete all the keychain folder:
rm -rf /Users/my_user/Library/Keychains
Rebooted the mac, installed keys again, and everything worked as expected.
Disclaimer: First make a backup of all the needed keys! (export before delete) For any service like Chrome sign-in, you will need to enter your credentials again
I have a very dreadful answer of this. I dont know what was corrupted in my system but after so many reinstallation and deletion of xcode still didn't solve the issue. So I formatted my hdd and reinstall mac OS Sierra and xcode 8 and that solved the issue
Try under Window tab => Organizer, the provisioning that are in your device. Then re-add them (download them again on the apple website). And try to compile again.
Xcode 8 allows you automatic signing. You need to select your target in settings -> General. And you will see the checkbox like on the image:
When you check this checkbox, you will need to choose your team (like in red rectangle on the image). After that Xcode will create a team provision profile for your application, and your application will be signed automatically.
P.S. I you don't see your team in the team dropbox like on the image, you need to Xcode -> Preferencies:
After that you need to enter "Accounts" tab -> tap + button:
After that you the team with your developer account will appear in the Team dropbox like on the 1st image.
I deleted a key named "1" in keychain access.
Then xcode has become to work!

Fixing Command /bin/sh failed with exit code 1

That the error xcode appear:
I had already tried that question no helpful:
Code Sign Error - Command /usr/bin/codesign failed with exit code 1
I'm trying to upload an App from a not mine account.
I've imported the profile to Xcode.
I've the .mobileprovision for distribution and .p12 certificate already imported.
But when I try to archive I get the above error.
How can I fix it?
As stated above, cleaning Derived folder, clean and Archive helps. If nothing helps, follow most common solution for computer science problem - Restart the MacBook and try again. It did work for me.
~/Library/MobileDevice/Provisioning Profiles
Remove all old files, re-install the new profile,set the right profiles in
code signing/provisioning profiles
Man there is no issue with your code or pod files , i had face the same issue and the solution was to choose the right provisioning profile of my app
go to build settings --- code signing and under provisioning profile make sure that u chooed the right 1
BR

Xcode's Bot always returns error

I got an issue with Xcode's Bot. It always returns the "User canceled the operation. Command /usr/bin/codesign failed with exit code 1" error string after running the command below:
/usr/bin/codesign --force --sign <MY_PRIVATE_KEY> --entitlements /Library/Developer/XcodeServer/Integrations/Caches/2cdd321641e8c114e4eba9819b017479/DerivedData/Build/Intermediates/MyApp.build/Debug-iphoneos/MyApp.build/MyApp.app.xcent /Library/Developer/XcodeServer/Integrations/Caches/2cdd321641e8c114e4eba9819b017479/DerivedData/Build/Products/Debug-iphoneos/MyApp.app
I can run this command in Terminal with sudo. I'm using Xcode 6.3.1 and OS X Server 4.1.53 in my Mac 10.10.4.
Thank for your help.
This looks like a code signing error. There are a few different reasons for this to happen so you will need to do some troubleshooting. Can other bots build on your server? If so then its probably a build settings issue in this specific project.
In the Xcode Project go to the Project Target that your trying to build, and then Build Settings, and Code Signing. Under the Provisioning Profile you can either choose Automatic or explicitly choose the correct provision, and then under the Code Signing Identity choose iOS Developer. This is probably where your issue is if its related to the project. Do you have a proper provision setup for the project on the Apple Developer Portal?
If you can't get any bots to run on your server then the issue could be with how you set up Xcode Server. Have you added the server to your team? Here is the blog post that I used to get mine up and running, although you don't need to do all of those steps in the post. Focus specifically on the Setup Certificates section and Setup Provisioning Profiles section.
I fixed the issue by copying the missing provisioning file from my local directory "/Users/phuongle/Library/MobileDevice/Provisioning Profiles" to "/Library/Developer/XcodeServer/ProvisioningProfiles". Do not use the downloaded provisioning file from developer.apple.com directly.
I just want to note here for everyone having the same issue with me.

Xcode 5 "error: can't exec 'codesign' (No such file or directory)"

Someone recently posted a similar issue at can't exec 'codesign' (No such file or directory)
However, for whatever reason, it has received a down-vote rather than something helpful. So I am going to try to post this myself, with some additional data in hopes that some kind SO'er has been through this or just knows what the problem is.
I have a project that builds fine under Xcode 4.x, but ever since installing Xcode 5 DP2 (and DP3,4 and 5) and now the released version, I get this error when trying to build or archive to anything but the simulator:
CodeSign /Users/cb/Library/Developer/Xcode/DerivedData/MyApp-bdtrjmwxxokvesathmrttgwwesfq/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app
cd /Users/cb/Development/MyAppCore/FrontEnd/Mobile/iOS/MyApp
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:$PATH:/usr/local/mysql/bin:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin"
Using code signing identity "iPhone Developer: CB (D4HZSHL6DF)" and provisioning profile "MyApp_DEV" (BB1C0589-147E-4E12-945D-8FB093B70C70)
codesign --force --sign F5...B73 --resource-rules=/Users/cb/Library/Developer/Xcode/DerivedData/MyApp-bdtrjmwxxokvesathmrttgwwesfq/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app/ResourceRules.plist --entitlements /Users/cb/Library/Developer/Xcode/DerivedData/MyApp-bdtrjmwxxokvesathmrttgwwesfq/Build/Intermediates/ArchiveIntermediates/MyApp/IntermediateBuildFilesPath/MyApp.build/Release-iphoneos/MyApp.build/MyApp.xcent /Users/cb/Library/Developer/Xcode/DerivedData/MyApp-bdtrjmwxxokvesathmrttgwwesfq/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app
If I open Terminal and cd to
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/
and then run the command from there, it executes just fine. So the tools seem alright, as do the provisioning profiles. The problem seems to be with Xcode itself.
It should be noted that I have deleted Xcode completely, as well as my codebase, along with all provisioning profiles and certs. I re-checked-out my code, and re-installed Xcode 5 from a fresh download, entered Apple ID into Xcode and re-created/fetched the certs and profiles, and still have the same issue.
I also went in to the project file itself and removed duplicate PROVISIONING_PROFILE entries per a couple of answers I found, to no avail.
I can build this same project from 2 other machines using Xcode 5, so it is something happening specifically on my box, or with my particular installation, it would seem. But other than that, I am stumped.
Has anyone seen/fixed this, or have any ideas of where to look for an answer?
Thanks for any input!
I copied codesign from /usr/bin/
to:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/u‌​sr/bin
and it worked for me.
Try this:
For Mountain Lion before starting signing process Please run below command as first command.
For Xcode 4.x:
export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/usr/bin/codesign_allocate"
For XCode 5:
export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate"
Solved my problem, thanks for the help. The issue was with my path. I had set my path via /etc/launchd.conf and I was driving myself insane trying to edit my path via ~/.bashrc etc. Make sure /usr/bin is in the path that xcode picks up. This page reminded me: http://overwatering.org/blog/2012/08/setting-path-osx-mountain-lion/
If you added the flag --deep to "Other code signing Flags" i.e. using cut copy paste, it may happen that an "invisible" char was added. In this case the error message is like:
/usr/bin/codesign --force --sign "" --deep --entitlements (...)
No such file or directory
If you see those two quotes "" then there is an invisible char before '--deep' in your compiler settings.
In this case the compiler throws the error message "No such file or directory".
(/usr/bin/codesign seems to not be existing, but it is (!))
To resolve this issue go to build settings, search for 'Other code Signing Flags', delete all entries, and retype them manually (no cut copy paste).

iOS Enterprise: Re-certify existing IPA with new certificate

We are enrolled in the iOS Enterprise Program. The provisioning profile used for our released apps is about to expire, so I got a new certificate and provisioning profile.
I need to re-distribute some of our apps with the new provisioning profile, without building them anew. How?
(I vaguely remember seeing a utility program that did exactly this: You choose an IPA and a provisioning profile, and it would create a new IPA using the new profile and certificate. What was the tool’s name, and where can I get it?)
In theory whoever built the last IPA in XCode should have used Archive - this creates a build you can sign to create an IPA (using XCode).
You could also try using the command line signing tool XCRun to re-sign the App bundled in your existing IPA:
http://skabber.com/package-your-ios-application-with-xcrun
OK, turns out when you know what term to google, there‘s lots of excellent resources…
They all point to xcrun. I made it work with this shell snippet, adapted from this promising build script:
APP_FILENAME=MyApp.app
BUILD_DIRECTORY=/Path/To/Target/Dir
IPA_FILENAME=MyApp.ipa
DISTRIBUTION_CERTIFICATE='iPhone Distribution'
PROVISIONING_PROFILE_PATH='/Path/To/Profile.mobileprovision'
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "$APP_FILENAME" -o "$BUILD_DIRECTORY/$IPA_FILENAME" --sign "$DISTRIBUTION_CERTIFICATE" --embed "$PROVISIONING_PROFILE_PATH"
The codesign command-line utility, included with the iOS SDK tools, will allow adding/changing the certificate and provision with which a developer built app is signed.
As hotpaw2's anwaswer states. You can also resign using the codesign tool.
The way I do it (this may not be the most efficient, but it works)
Rename the .ipa to a .zip and extract
Run The following:
/usr/bin/codesign -f -s "iPhone Distribution: Company Name" "Payload/MyApp.app"
Re-zip the Payload folder and rename to .ipa
Note: You can also use this method to edit the embedded.mobileprovisioning file! Just remember to remove the .DS_Store (rm Payload/.DS_Store) if you are using finder.
You can do manual way if you just resigning app from same account with following steps.
All this is using shell script and super easy provided you know how to use shell commands.
Rename IPA to zip
unzip this file to temp folder
Remove the old _CodeSignature folder from all targets (if you have multiple targets like main,watch, watch extn, siri, widget, message, etc)
bring all the targets prov-profiles in one folder and replace all the embedded.provisioningprofile files for each target with the new ones
remove the archived....xccent file as this is old one (optional)
code sign with the entitlements.plist created for all the entitlements if any used by the app.
Zip the folder back after code sign all okay with no errors
Rename the zip to IPA
Note: To validate the IPA before upload to apple you can just use the altool from inbuild XCode App Loader to check the new IPA.
Reference: The steps for commands is also explained here:
http://www.enterpriseios.com/forum/topic/Resigning_3rd_party_apps
If you want to get rid of manual sign use the fastlane tool as its quite simple and easy to configure.https://fastlane.tools/

Resources