Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 10, Command CodeSign failed with a nonzero exit code

Tags:

xcode

ios

xcode10

I had that problem and Xcode failed to compile on the device, but on simulator, it worked fine.

I solved with these steps:

  1. Open keychain access.
  2. Lock the 'login' keychain.
  3. Unlock it, enter your PC account password.
  4. Clean Project in the product menu.
  5. Build it Again.

And after that everything works fine.


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.


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


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.


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

  • https://developer.apple.com/library/archive/qa/qa1940/_index.html

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.