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

Solution 1:

I had the exact same error, and tried everything under the sun, including what was suggested elsewhere on this page. What the problem was for me was that in Keychain Access, the actual Apple WWDR certificate was marked as "Always Trust". It needed to be "System Defaults". That goes for your Development and Distribution certificates, too. If any of them are incorrectly set to "Always Trust", that can apparently cause this problem.

So, in Keychain Access, click on the Apple Worldwide Developer Relations Certificate Authority certificate, select Get Info. Then, expand the Trust settings, and for the combo box for "When using this certificate:", choose "System Defaults".


Sigh: for those insistent on downvoting this answer, I am not claiming this to be the only solution for this problem. It's one solution. It may not work for you. There are multiple reasons for this codesign failure.

Solution 2:

I had the exact same problem and this did the trick for me:

Xcode > Preferences > Accounts > View Details > And just refresh the Provisioning Profile

Seems like the accounts in Xcode were not updated with the latest provisioning profiles so a quick refresh sorted this out.

Solution 3:

Feel the need to share this, even though it's ridiculous.

I'd set up a second developer account on my Mac and couldn't codesign anything. The error was "the user cancelled the operation".

A simple reboot fixed this for me.

Solution 4:

I was fighting for about 2-3 hours to codesign a project with Parse API. It turned out that the embedded frameworks caused the problem. Make sure you set "Code sign on copy" (see picture). If does not work delete the Parse and Bolts frameworks from the list and remove them from your project then add them again.

enter image description here

Solution 5:

What worked for me was to realize that Xcode did not have access to the certificates. Please check that your certs are accessible by Xcode. Go to Keychain Access -> Certificates -> Open the Cert and double click on the private key -> Select Access Control

enter image description here