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

CodeSign /Users/ogystoev/Library/Developer/Xcode/DerivedData/APPNAME-/Build/Intermediates/ArchiveIntermediates/APPNAME/InstallationBuildProductsLocation/Applications/APPNAME.app

cd /Users/ogystoev/Documents/WORK/APPNAME/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/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"


Signing Identity: "iPhone Developer: ....."

Provisioning Profile: "iOS Team Provisioning Profile: ....."

()

/usr/bin/codesign --force --sign --entitlements /Users/ogystoev/Library/Developer/Xcode/DerivedData/APPNAME-/Build/Intermediates/ArchiveIntermediates/APPNAME/IntermediateBuildFilesPath/APPNAME.build/Release-iphoneos/APPNAME.build/APPNAME.app.xcent --timestamp=none /Users/ogystoev/Library/Developer/Xcode/DerivedData/APPNAME-/Build/Intermediates/ArchiveIntermediates/APPNAME/InstallationBuildProductsLocation/Applications/APPNAME.app



Please, I need a help about this error


I can not sign any of my apps.


This is an issue with Sierra and Xcode 8

Also seeing this issue.

There's a few recent threads about exit code 1 / "detritus" but their recommendations (xattr commands) don't work for this exit code 5 issue.

Would like to avoid having to setting up El Capitan, but that may be the only route.

Anyone find a way through this one?

Anyone with solution?

The only solution I've found is to build and archive on a machine still running El Capitan. This works fine, keeping everything else the same.

http://stackoverflow.com/questions/39664079/command-usr-bin-codesign-failed-with-exit-code-5


What doesn't work

- regenerating certificates and provisions (https://forums.developer.apple.com/thread/64677)

- fixes for exit code 1

- restarting xcode, rebooting, etc

- deleting derived data

- deleting and reinstalling certificates/keys in Keychain Access on the mac

- updating to Sierra 10.12.1 developer Beta 5

- updating to Sierra 10.12.1 release (Oct 24)

Anyone find a solution?

I got same issue too. Any one help ?

Please, Apple ... do something.


This is verry irritating...

I've sent many emails to Apple DTS iosdtssupport@apple.com

But still there is no solution

Filing a bug report here would help too. If they get enough of the same bug, they're more likely to look at it.

https://bugreport.apple.com

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

Referring to _alexrr, I deleted a key named "1" in keychain access.

Then xcode has become to work!

(I haven't delete all items in keychain, just deleted one named "1.")

It's NOT working for me ):

I can confirm this.


Opened Keychain

Scrolled down "All Objects" to Key "1"

deleted Key "1"

rebooted Macbook

and "Voila". I am able to Code Sign again without Exit Code 5


(I tried almost anything else from above before without success)

working for me, BUT make sure to delete key "1" that is in keychain <your username>/ not the one in login/

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