How to fix "no identity found - Command CodeSign failed with a nonzero exit code" error in Xcode

⋅ 1 min read ⋅ Xcode

Table of Contents

Today I got the "Command CodeSign failed with a nonzero exit code" error with the following information.

Signing Identity: "My identity"
/usr/bin/codesign --force --sign xxxxxxxx --timestamp=none /path/to/derived/data...
xxxxxxxx: no identity found
Command CodeSign failed with a nonzero exit code

There might be several reasons that cause this error. I will share one that just happened to me.

You can easily support sarunw.com by checking out this sponsor.

Sponsor sarunw.com and reach thousands of iOS developers.

Cause of the problem

I got this problem when I mess up with keychains in the Keychain Access app. I created a new certificate and tried to delete an old one. And I think Xcode was attempting to use the deleted one.

You can easily support sarunw.com by checking out this sponsor.

Sponsor sarunw.com and reach thousands of iOS developers.

Solution

My solution is what we always do when we got an Xcode problem, Clean Build Folder.

  1. Click menu Product > Clean Build Folder while holding down option key or ⌘ - CMD + ⇧ - SHIFT + ⌥ - option + K.
  2. Close the Xcode. This is a very important step for me. I need to close it to work.
  3. Reopen the app, and you might see the dialog asking to access the keychain. Grant the access, and the problem should go away.

Read more article about Xcode or see all available topic

Enjoy the read?

If you enjoy this article, you can subscribe to the weekly newsletter.
Every Friday, you'll get a quick recap of all articles and tips posted on this site. No strings attached. Unsubscribe anytime.

Feel free to follow me on Twitter and ask your questions related to this post. Thanks for reading and see you next time.

If you enjoy my writing, please check out my Patreon https://www.patreon.com/sarunw and become my supporter. Sharing the article is also greatly appreciated.

Become a patron Buy me a coffee Tweet Share
Next
Using App Store Connect API with Fastlane Match

Apple announced the App Store Connect API back in WWDC18. It provides an official way to interact with App Store Connect, and Fastlane already supports this. With a recent 2FA enforcement from Apple, it is time for you to adopt it.

← Home