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

Viewed 132542

I have the following error:

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

Here is what I already did for trying to fix this:

  • set the bundle identifier to com.server.pgmname
  • set the code signing to "Any Iphone OS Device"
  • set the Code Signing Identity to my Distribution identity.

The error only occurs when I try to build on my device, on the simulator everything works fine.

Do you have any suggestions?

44 Answers

For anyone with this problem in the future (who doesn't want to rebuild their project), an additional question to ask is whether you have a space in your product name. I'd recommend going through your properties (right-click -> get info) of your project and your target. For my project, the only place that a space was needed was in the plist for the bundle display name.

Very often the error /usr/bin/codesign failed with exit code 1 occurred in case the user has no file extensions for texture files in Models.scnassets folder. macOS very often generates a files with hidden extensions.

For example: you have a file myTexture but it must include an extension as well – myTexture.png.

Here is my way to resolve:

  • Open keychain access, select your iOS certificate, Delete private key
  • Then go back to xCode, you will see warning warning message and "Revoke" button, click it and error resolved.

In my case, I had an extra expired distribution certificate in my keychain - I deleted the certificate from KeyChain Access and the compilation started working again.

I recently had the same issue. Keychain Access was the culprit.

Steps: Go -> Utilities -> Keychain Access Keychain Access: Edit -> Change Password for Keychain "login"

Change the password. Close and reopen Xcode, Clean & build again.

If option - Change Password for Keychain "login" - is greyed out:

  1. Make sure under Keychains selected -> login and the padlock icon is open. To open the padlock you need the keychain password. If you do not know the password, go to Step 2.

  2. With padlock unlocked and still option is greyed out. As last resort: Keychain Access -> Preferences Preferences: "Reset My Default Keychains" Reset the login. However be careful as stored keychains will be removed and you may have re-login on other connected devices as well.

This issue occured when I added a folder named "Resources" as "Create folder references", and when I renamed "Resources" to another random name, this issue disappeared.

Hope it will help.

Spent hours figuring out the issue, it's due very generic error by xcode. One of my frameworks was failing with codesign on one of the laptop with below error :

XYZ.framework : unknown error -1=ffffffffffffffff

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

However, there is no Codesign set for this framework and still it fails with codesign error.

Below is the answer:

I have generated new development certificate (with new private key) and installed on my new mac.

this error is not relevant to XYZ.frameowrk. Basically codesign failed while archiving coz we newly created certificate asks "codesign wants to sign using key "my account Name" in your keychain" and the buttons Always Allow, Deny and Allow.

Issue was I never accepted it. Once I clicked on Allow. It started working.

Hope this helps.

For me it worked by doing following:

  1. delete all existing dev certificates in "login"

  2. then go to a xcode project -> go to a target -> General -> select a team.

  3. after you select that just follow the things which will appear below(try again button & stuff..). At the end you have to provide your "login" keychain password

After "3." you will see into your "login" keychain the new certificates and also for me no more code signing error.

All I had to do is to disable automatic signing, then re-nable it, and choose my team identity. And it worked!

Tried out most of the solutions here and what helped me was cleaning the build folder in XCode using: Product - > Clean and rebuild the project

In Xcode: Go to Preferences Logout of the current user.

Close Xcode

In Keychain: Go to Login and All items

            - Sort by kind
                 - remove "Apple Worldwide Developer Relation Certification Authority"
                 - remove "Developer ID Certification Authority"
                 - remove "iPhone Developer ...."

Open Xcode

Go to Preferences and Login to you user apple account

- This will reload your developer certificates you previous deleted 

Rebuild the project (Should be a successful build)

Run the build on your native device

I ran into this error code with an existing project that suddenly wouldn't sign after I added three PNG files to the project. It turns out that one of the PNG files was the culprit. All three PNG files were created with Pixelmator, should have the same structure. But it simply wouldn't sign with one of the images. Remove the image, it worked. Add it again, failed. Rename the image, still failed. I wound up building a new image from scratch, all fixed.

That worked for me was to review all the certificates on KeyChain to be as Use systems Default, all the certificates must to be with this configuration. Was the only thing that worked, and also be shure that no certificates are repeated.

For me, I just had to delete "Derived Data" in xcode

Open Xcode (12.3) -> Xcode -> Preferences -> Locations -> Click DerivedData location arrow -> Delete "DerivedData" folder -> Clean and build

Steps to Fix this issue:

  1. Go to Key Chain Access.
    1. Select the i-Phone Developer certificate.
    2. Lock the Certificate.( Menu bar - Lock Button)
    3. Give the Machine Password.
    4. Unlock the Certificate.

Now clean and rebuild the project, this issue will resolve.

I have solved this issue by following steps.

  1. open keychain access, type "deve"
  2. delete the selected item as in the attached image enter image description here
  3. open xcode and it will ask password type system password.

Hope, it will help.

Related