Xcode 10, Command CodeSign failed with a nonzero exit code
IosXcodeXcode10Ios Problem Overview
Every time I build a console is showing this message.
>CodeSign /Users/admin/Desktop/AppStoreBuild/Project201/build/Debug-iphonesimulator/Project.app (in target: Desker) cd /Users/admin/Desktop/AppStoreBuild/Project201 export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
Signing Identity: "-"
/usr/bin/codesign --force --sign - --entitlements /Users/admin/Desktop/AppStoreBuild/Project201/build/Project.build/Debug-iphonesimulator/Project.build/Project.app.xcent --timestamp=none /Users/admin/Desktop/AppStoreBuild/Project201/build/Debug-iphonesimulator/Project.app
>/Users/admin/Desktop/AppStoreBuild/Project201/build/Debug-iphonesimulator/Project.app: resource fork, Finder information, or similar detritus not allowed Command CodeSign failed with a nonzero exit code
... Is there any way to identify the cause of this failure? It's showing Signing Identity: "-" when I try to run in the simulator also. why do we need signing identity in simulator? And one more thing is if I quit Xcode and restart, it will build properly when I change code or add a method will again build failing.
Ios Solutions
Solution 1 - Ios
I had that problem and Xcode failed to compile on the device, but on simulator, it worked fine.
I solved with these steps:
- Open keychain access.
- Lock the 'login' keychain.
- Unlock it, enter your PC account password.
- Clean Project in the product menu.
- Build it Again.
And after that everything works fine.
Solution 2 - Ios
None of the listed solutions worked for me. In another thread it was pointed out that including a folder named "resources" in the project causes this error. After renaming my "resources" folder, the error went away.
Solution 3 - Ios
For some people this happens after adding a .png file to an existing .scn assets folder, plus also a .wav file.
Xcode, owing to increased security, doesn't like extensions on files. You can fix these one at a time by cd
'ing into the directory where the file is and removing their extended file attributes using the 'xattr' command in Terminal.
To Remove All Extended Attributes On a Single File
Use xattr with the -c flag to "clear" the attributes:
xattr -c yourfile.txt
To Remove All Extended Attributes On Many Files
To recursively remove extended attributes on all files in a directory, combine the -c "clear" flag with the -r recursive flag:
xattr -rc /path/to/directory
Fore more detail, see https://stackoverflow.com/questions/4833052/how-do-i-remove-the-extended-attributes-on-a-file-in-mac-os-x
This solution will also help when getting the code signing error: "resource fork, Finder information, or similar detritus not allowed."
Apple documentation: https://developer.apple.com/library/archive/qa/qa1940/_index.html
Solution 4 - Ios
This happened to me just today, only after I added a .png image with 'hide extension' ticked in the get info. (Right click image) Ths image was added to the file directory of my Xcode project.
When unticked box and re-adding the the .png image to directory of Xcode, I then Cleaned and Built and worked fine after that, a very strange bug if you ask me.
Solution 5 - Ios
Fix
Remove extended file attributes in your resource files for good, not in the compiled application bundle:
-
Open Terminal
-
Change directory to the root of your source files
$ cd /Users/rjobidon/Documents/My\ Project
-
List all extended attributes
$ xattr -lr .
- Remove all extended attributes
$ xattr -cr .
Xcode errors
- "Command CodeSign failed with a nonzero exit code"
- "Resource fork, Finder information, or similar detritus not allowed"
Cause
Apple introduced a security hardening change, thus code signing no longer allows any file in an app bundle to have an extended attribute containing a resource fork or Finder info.
Sources
Solution 6 - Ios
Try cleaning the project:
1. shift + cmd + k
2. shift + cmd + Alt + k
Then try to run your project again. Hope this will fix the problem.
Solution 7 - Ios
None of the popular solutions worked.
In my case, I resolved the error by going into the
> XCode -> Preferences -> Accounts -> Manage Certificates
and added a (+) to iOS development.
Solution 8 - Ios
This issue happened to me after adding .dae and .png files and converting .dae with XCode Editor to SceneKit scene file format (.scn).
After doing some more research I found the solution here - https://forums.developer.apple.com/thread/109951#336225
Steps to solve the issue:
- In XCode go to Preferences
- Click on Locations tab
- In Command Line Tools select from the drop down XCode 10.1
Solution 9 - Ios
In Xcode: Go to Preferences Logout of the current user.
Close Xcode
In Keychain: Go to Login and All items
- Sort by kind
- remove "Apple Worldwide Developer Relation Certification Authority"
- remove "Developer ID Certification Authority"
- remove "iPhone Developer ...."
Open Xcode
Go to Preferences and Login to you user apple account
- This will reload your developer certificates you previous deleted Rebuild the project (Should be a successful build)
Run the build on your native device
Solution 10 - Ios
This is because Code signing no longer allows any file in an app bundle to have an extended attribute containing a resource fork or Finder info.
To see which files are causing this error, go to
cd <above path>
xattr -lr .
You will see some files has extended attribute:
./MyProject.app/Contents/Resources/shopping_cart.png: com.apple.lastuseddate#PS: 00000000 BE 31 D5 5E 00 00 00 00 D0 40 FE 39 00 00 00 00 |.1.^[email protected]....|
Then go to your project folder or referenced folder for those files, remove extended attribute:
cd /Users/XXXX/Work/MyProject
xattr -cr .
After clean all referenced folders, go to Xcode and rebuild.
Solution 11 - Ios
The solution for me was restarting macOS without saving
Solution 12 - Ios
I'm unsure of what causes this issue but one method I used to resolve the porblem successfully was to run pod update on my cocoa pods.
The error (for me anyway) was showing a problem with one of the pods signing. Updating the pods resolved that signing issue.
pod update [PODNAME] //For an individual pod
or
pod update //For all pods.
Hopefully, this will help someone who is having the same "Command CodeSign failed with a nonzero exit code" error.
Solution 13 - Ios
In my case was the following errors lines:
> Signing Identity: "-" > > …..mobile.app: resource fork, Finder information, or similar detritus > not allowed > > Command CodeSign failed with a nonzero exit code
the problem was that in the resources folder I had some files with .png extension, which was hidden on the defaults.
Find file in FINDER, mark it -> cmd+i -> unchek Hide extension
after that, return in Xcode -> kmd + shift + K and rebuild.
I hope I've been helpful!
Solution 14 - Ios
For me the solution was the following, having the "Automatically manage sign" flag on:
-
in the team drop-down of the target, select "None"
-
re-select the correct development team
After trying almost every suggestion, I found that this works, I guess because Xcode sets up the signing stuff from scratch.
Solution 15 - Ios
After trying everything, my solution was removing some PNG files, build and run (ok) and adding again the PNG images. Weird!
Solution 16 - Ios
I will post my solution. This solution worked for me, since none of the previous worked. The issue first occurred right after last update of XCode cli toolset (not sure if this is the confirmation bias).
I tried some of the instructions (ie. Unlock Keychain Trick).
What worked for me in a case of error:
-
Command CodeSign failed with a nonzero exit code (Something.framework)
- Trash DD Content; rm -rf /Users/dx/Library/Developer/Xcode/DerivedData/*
- Restart XCode
- Build Phases =>
Link Binary With Libraries
*Something.framework
, - Set embed value in
General => Something.framework => EMBED
*Do not embed
- Press
Cmd+B
(Build Project) - Hopefully Built Successful
Solution 17 - Ios
In my experience, the reason that caused this problem was I wrongly reset the Keychain Access to default, so I lost my development certificate.
How did I solve this?
- I cleaned my Apple Development Certificate from Keychain Access
- I cleaned my Apple Development private key from Keychain Access
- Then I got the new error : Revoke certificate Your account already has an Apple Development signing certificate for this machine, but its private key is not installed in your keychain. Xcode can create a new one after revoking your existing certificate.
- Go to Xcode Preference -> Accounts Tab -> Fine the team name under the Apple ID -> Double Click it -> Click the + button at the bottom left of box -> Select App Development
- In the team drop-down of the target, select "None"
- Re-select the correct development team
- Clean the project by shift+cmd+k
- Rebuild the project cmd+b
Solution 18 - Ios
I, too, saw this error after adding a mixture of .jpg and .png images to the art.scnassets folder, making code changes, and removing those changes via Xcode's Source Control > Discard All Changes... menu.
I tried the other fixes in this thread but, ultimately, I had to delete the added .jpg/.png files, clean the project, and rebuild the project to eliminate the errors. I then readded the original .jpg/.png files and I'm now rebuilding the code without issue.
Solution 19 - Ios
For me I had to go to keychain, select the "login" keychain, double click on the iOS Developer:myname key, click the access control tab and switch the radio button to Allow all applications to access this item.
Solution 20 - Ios
This problem was caused by building my project in the Release schema. It can be caused by other things as well. Try to switch the build schema by going in xCode to Product > Scheme > Edit Scheme. In the "Run" Section located on the left, switch the "Build Configuration" to "Debug". I hope this will help.
Solution 21 - Ios
None of the above solutions worked for me. After some guess work, I tried (Xcode v10.2.1 cocoapods v1.7.1)
pod deintegrate
followed by
pod install
Then:
- Opened the workspace in Xcode
- Cleaned build folder
- Build the project
No build errors.
Solution 22 - Ios
My Problem was solved
- Check Automatically manage signing on Target MyProject and Add Team.
- Check Automatically manage signing on Target MyProjectTest and Add Team.
- Product -> Clean Build Folder -> Build again or try to run on device.
The problem occurs when you have the wrong/different team on MyProject and MyProjectTest.
Reconnecting your phone prior to rebuilding may also assist with fixing this issue.
Solution 23 - Ios
I was experiencing this issue due to the misconfiguration of my Apple Worldwide Developer Relations Certification Authority certificate.
I resolved issue by switching from "Alway Trust" to "Use System Defaults"
Step by Step:
- Open KeyChain
- Click on "login" keychain (make sure it's unlock - if it's locked Right Click on it and choose "Unlock KeyChain")
- Click on Certificates and locate Apple Worldwide Developer Relations Certification Authority certificate
- Right click on it and choose Get info
- Expand Trust section and change settings to Use System Defaults as per below screenshot
Solution 24 - Ios
This issue can also occur when upgrade from XCODE 11.x to 12.0. After installation of new version of XCODE, restart system to overcome this issue.
Solution 25 - Ios
Not sure if this will help anyone - but make sure you have Find Implicit Dependencies
checked off. Sometimes this can lead to your project "losing track" of where to look for certain things.
Once you do this, I suggest then also cleaning your project and rebuilding.
Solution 26 - Ios
None of other answers worked. This is what I have done:
- deleted my certificate from keychain;
- opened Xcode it rebuild certificate;
- ran app on device successfully.
Solution 27 - Ios
in my case it was a corrupted storyboard file
Solution 28 - Ios
After i copied two .aiff files in a .scnassets group, this error occured. Deletion of the files and a "Clean Build Folder" solves the problem in my case.
Solution 29 - Ios
This worked for me :) I removed the certificate in keychain access settings. Go to Xcode and clean build the app. Now certificate is again created in keychain access and build gets succeeded with real device.
Solution 30 - Ios
Solution 31 - Ios
In my case it was an accidentally turned on option. I'm using common root .xcconfig files both for iOS and macOS, for the iOS target the Enable hardened runtime option remained on so replacing the line
ENABLE_HARDENED_RUNTIME = YES
by the
ENABLE_HARDENED_RUNTIME[sdk=macosx*] = YES
in the .xcconfig file solved the issue
Solution 32 - Ios
May sound stupid, but, try with no password, when it asked.
Solution 33 - Ios
For me the highest rated answer didn't work.
What did work was to go to Signing and Capabilities -> Team -> add account and add the Apple ID again.
After doing this, when I built again I was asked for my login credentials and the build succeeded.
Solution 34 - Ios
I tried all of the above soloutions. none of them worked. I figured out that I had 2 keychains. Both of them had certificates and keys. I´ve deleted one keychain and removed all its key and certificates and just kept the "login" keychain. I´ve also removed everything from this keychain and then redownloaded the certificate from the apple developer page. After doing so everything was imported just into this ONE keychain. Cleaned Xcode, started. no problems!
Solution 35 - Ios
It works for me by delete all the apple developer Certification in the keychain. and generate it in the Xcode.
Solution 36 - Ios
I had just added the SystemConfiguration.framework and Reachability h and m when the issue began. I tried all of these solutions and ended up removing systemConfiguration.framework and that fixed it for me. The Reachability h and m are still in the project.
Solution 37 - Ios
What worked for me (Xcode 11.3.1 on Catalina 10.15.5.)
FYI - I have no team. I went to "Signing and Capabilities" for the build and the "Automatically manage signing" was already unchecked.
I checked it, which brought up a menu saying that it will reset some build settings. I clicked "Enable Automatic". Then I went back and unchecked the "Automatically manage signing" again to put it back to the way it was.
Worked after that.
Solution 38 - Ios
None of the bulk action solutions have worked for me. The extended attributes don't get removed. Each time this has happened for me it was a problem with one or more 3D models (.dae) or a .png file.
I have found that removing attributes (detritus) one file at a time works out to be faster in the end. I had to switch to the art.scnassets directory in terminal. (You can drag it from finder to terminal) For each suspect (new) file, I ran "xattr -lr filename.ext" to see if it had extended attributes. If so, I ran "xattr -cr filename.ext" to remove them. It has worked every time, but only by removing the attributes for each file. Then use Product - Clean Build Folder, and Build again. It has worked every time without fail.
Solution 39 - Ios
Finaly!!
I guess xcode doesn't allow running an app on local iPhone if you are not using iOS Certificate! I had only Distribution certificate and everything was fine except this error when trying to run on local device. After I've made an iOS Developer certificate the issue went away
Solution 40 - Ios
My case: I have removed the certificate, which is included on the profile.
My solution:
- Remove all profile at: /Users/{yourusername}/Library/MobileDevice/Provisioning Profiles
- Re-add profile.
Solution 41 - Ios
What worked for me - found elsewhere - was very simple:
flutter clean
(run it in Terminal from the base dir of the project)
Note that Clean Project in XCode did not make a difference, tried that first.
Solution 42 - Ios
Amazingly, none of the 30 answers so far mentions the issue I faced and the corresponding solution. For me, the exact error message was errSecInternalComponent Command CodeSign failed with a nonzero exit code
.
The error message appeared when running a command-line build from a remote (ssh) login. Running the same build command in the macOS desktop terminal window, caused a dialog box asking me for my password to pop up. After entering my password, the build succeeded.
Solution 43 - Ios
I fixed this issue only by renaming Resources
folder (not group) to any other names such as Resource
, Resources123
, etc.
Solution 44 - Ios
In my case, some special marks in the png files output by Paint.app causes this happen.
My solution is
step 1. drag the png files(if you do not know which png, please drag all png files in your project resource folder/group) caused the error happens to Preview.app
step 2. adjust image size,
step 3. enlarge 2 times for width and height, click 'Ok' button
step 4. set back to original width and height, click 'Ok' button
step 5. repeat step 3 and step 4 for all png images
step 6. clean project and build again