If you work with Xcode code signing long enough you’ll run into an error like this:
/usr/bin/codesign failed with exit code 1
If you view the build results (Build->Build Results), and expand the error message (there is a little paragraph button on the right-hand side of the line) you may see something like this:
iPhone Developer: Firstname Lastname (hashcode): ambiguous (matches "iPhone Developer: Firstname Lastname (hashcode)" in /Library/Keychains/System.keychain and "iPhone Developer: Firstname Lastname (hashcode)" in /Users/username/Library/Keychains/login.keychain)
Command /usr/bin/codesign failed with exit code 1
You have two certificates, with the same unique identifiers. One is in your login keychain and the other is in your system keychain. The real problem is, you probably have an expired certificate conflicting with your active certificate.
See my video explaining how to fix Xcode codesign failed with exit code 1; expired certificates causing ambiguous matches. You can also follow along with the screenshots below.
You wouldn’t know it when viewing the Keychain Access app. When you view your login certificates it will probably look like everything is fine. Open Applications->Utilities->Keychain Access. Then select the login keychain and Certificates category. Everything will probably look fine.
And when you view your system certificates, there won’t be anything there either. Select the System keychain and Certificates category.
You have to show expired certificates. For some reason, this isn’t on by default. From the menu, choose View->Show Expired Certificates.
Then you will see the offending certificate with an onerous red x circle.
Just delete the old certificate and build again.
I hope this saves someone some time.
- How to fix Xcode codesign failed with exit code 1; expired certificates causing ambiguous matches video explanation
- Code Signing Guide (Apple)
- TN2250: Understanding and Resolving Code Signing Issues (Apple)
- How to fix other iPhone code signing errors (codza)