Test Test
Test Test

Reputation: 1911

Xcode 10, Command CodeSign failed with a nonzero exit code

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.

Upvotes: 179

Views: 212329

Answers (30)

Nike Kov
Nike Kov

Reputation: 13761

Xcode Version 15.4 (15F31d)

  1. Clean build (Cmd+K)
  2. Exit xcode
  3. Open Keychain, remove development certificate and Apple Worldwide Developer Relations Certification Authority
  4. Open xcode, build and it should ask you the password for mac to access the keychain.

Upvotes: 0

mcfisty
mcfisty

Reputation: 207

This happened to me when my Mac device was very low / out of memory. The only solution was to free up space by deleting unused applications, and that resolved the issue.

Upvotes: 2

Muhammad Ahmad Mahmood
Muhammad Ahmad Mahmood

Reputation: 107

My solution was moving the project dir to a folder that is not synchronized with iCloud. And It worked. I saved it to Desktop first which was iCloud Synced later moved no non Synced Folder

Upvotes: 2

Luis Ascorbe
Luis Ascorbe

Reputation: 2099

no previous solutions worked, in my case the only change I did was to add the GoogleService-Info.plist file from Firebase

The issue: I added a GoogleService-Info.plist into a folder (Resources), which then I added to the Xcode project with "Create folder references" checked.

The solution: after I removed the reference, and added the .plist file directly with "Create groups" instead, it works 🥲

add plist file with "Create groups" instead of "Create folder references" checked

Upvotes: 0

Shep Sims
Shep Sims

Reputation: 1560

I tried clearing XCode caches, all of the keychain stuff mentioned above, restarting XCode and nothing worked except... drum roll please...

Turning my Macbook off and back on again!!

This error has become a regular occurrence for me, always stemming from the Iterable SDK, but a quick reboot always fixes it

Upvotes: 1

Nitin
Nitin

Reputation: 49

I opened "Keychain access" and deleted the expired certificates. Then did a build and this error disappeared.

Upvotes: 2

Vitalya
Vitalya

Reputation: 166

Added png file to my xcode project and saw this "blue screen":)

"Command CodeSign failed with a nonzero exit code. Xcode 14."

Deleted png and everything is ok. Magic.)

Upvotes: 0

Michael
Michael

Reputation: 475

I fixed this issue only by renaming Resources folder (not group) to any other names such as Resource, Resources123, etc.

Upvotes: 2

xuzepei
xuzepei

Reputation: 1219

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

Upvotes: 58

Matt
Matt

Reputation: 365

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.

Upvotes: 0

arachide
arachide

Reputation: 8076

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

enter image description here

step 2. adjust image size,

enter image description here

step 3. enlarge 2 times for width and height, click 'Ok' button

enter image description here

step 4. set back to original width and height, click 'Ok' button

enter image description here

step 5. repeat step 3 and step 4 for all png images

step 6. clean project and build again

Upvotes: -3

Diomidis Spinellis
Diomidis Spinellis

Reputation: 19385

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.

Upvotes: 0

Pieter
Pieter

Reputation: 2711

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.

Upvotes: 0

Cường Nguyễn
Cường Nguyễn

Reputation: 15

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.

Upvotes: 0

Vadim F.
Vadim F.

Reputation: 1051

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

Upvotes: 0

Nate Mcdowell
Nate Mcdowell

Reputation: 112

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.

Upvotes: 0

iravinandan
iravinandan

Reputation: 737

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.

Upvotes: 1

Sheldon TT
Sheldon TT

Reputation: 79

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?

  1. I cleaned my Apple Development Certificate from Keychain Access
  2. I cleaned my Apple Development private key from Keychain Access
  3. 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.
  4. 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
  5. In the team drop-down of the target, select "None"
  6. Re-select the correct development team
  7. Clean the project by shift+cmd+k
  8. Rebuild the project cmd+b

Upvotes: 2

Sam Xu
Sam Xu

Reputation: 272

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 .app folder, normally is like: /Users/XXXX/Library/Developer/Xcode/DerivedData/MyProject-ckbzynxqjmstxigbdwwkcsozlego/Build/Products/Debug-maccatalyst/ (mine is Catalyst project) In Terminal,

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.

Upvotes: 6

rjobidon
rjobidon

Reputation: 3155

Fix

Remove extended file attributes in your resource files for good, not in the compiled application bundle:

  1. Open Terminal

  2. Change directory to the root of your source files

    $ cd /Users/rjobidon/Documents/My\ Project

  3. List all extended attributes

$ xattr -lr .
  1. 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

Upvotes: 24

marika.daboja
marika.daboja

Reputation: 1011

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:

  1. Open KeyChain
  2. Click on "login" keychain (make sure it's unlock - if it's locked Right Click on it and choose "Unlock KeyChain")
  3. Click on Certificates and locate Apple Worldwide Developer Relations Certification Authority certificate
  4. Right click on it and choose Get info
  5. Expand Trust section and change settings to Use System Defaults as per below screenshot

enter image description here

Upvotes: 2

sensation
sensation

Reputation: 437

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

Upvotes: 2

Mick
Mick

Reputation: 187

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.

Upvotes: 0

Bruce
Bruce

Reputation: 1698

It works for me by delete all the apple developer Certification in the keychain. and generate it in the Xcode.

Upvotes: 1

tyler
tyler

Reputation: 424

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!

Upvotes: 0

Matthew Webster
Matthew Webster

Reputation: 21

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.

Upvotes: 0

Nicoli
Nicoli

Reputation: 944

After trying everything, my solution was removing some PNG files, build and run (ok) and adding again the PNG images. Weird!

Upvotes: 2

myturmudi
myturmudi

Reputation: 440

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.

Upvotes: 1

Tiago Gouv&#234;a
Tiago Gouv&#234;a

Reputation: 16820

May sound stupid, but, try with no password, when it asked.

Upvotes: 0

Hofi
Hofi

Reputation: 976

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

Upvotes: 0

Related Questions