[ios] Command /usr/bin/codesign failed with exit code 1

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?

This question is related to ios iphone exit-code codesign

The answer is


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.

The solution that worked for me is related to (what I think is) a change of path behavior after upgrading to Xcode 4.2:

You can no longer manually enter "armv6 armv7" but must enter $(VALID_ARCHS) instead: both for the Architectures and Valid Architectures fields under the Architectures section in your project's Build Settings pane. Xcode will automatically replace the statement with 'armv6 armv7'.

This string looks exactly the same as if you would have typed it in manually but nevertheless point to the actual correct paths that will be generated along with your build, ...or at least this is my take on it :P

Unrelated, we used to have "armv6 armv7" as well under Other Signing Flags and now took that out and it works fine. This must be just an extra.

Thanks and happy hacking. Gon


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.


When I experienced this error, it was due to having been in Keychain Access, and choosing 'Disallow' when asked whether I wanted to let the program access a saved password. Going back in and selecting 'Allow' and typing my system password fixed the problem in XCode.


If anyone uses Xcode ver. 3.x.x and upgrades from Mac OS 10.7 to 10.8, dev. tools will work just fine except the new codesign binary .. To fix that just copy the old codesign and codesign_allocate binaries (I hope you have backup) to /usr/bin/ folder and rename or backup the new one.


For me the problem was HTTP proxy


I had special characters in the project name,renaming it to remove the characters, question marks, and insuring a developer certificate was enabled fixed the issue.


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


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.


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


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.


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.


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.


I got this error the very first time I tried to make a provisioning profile by following the Provisioning Assistant and it turns out they fail to mention the WWDR Intermediate Certificate. I installed it and it worked fine for me.


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.


I went to Key Access, selected the private key, and added XCode to the list of apps that can access it. That worked for me


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.


I had this same problem and couldn't figure it out for a long time. I tried everything on this page and others and it still didn't work. But eventually, I did find a fix.

For this to work, make sure Xcode is not running. After you've closed Xcode, open Terminal and type in the command:

xattr -rc /[The File Directory of your project found in the File Inspector of your .xcodeproj file in Xcode]/

Obviously don't put the text in brackets, just replace it with what it says. Hit enter. Don't worry if nothing shows up below the command, it didn't for me. After that, you can close out of Terminal and open Xcode. Now everything should be fine. Note: It might take a little longer to run your project, but just wait it out.

Also note: Don't downvote this answer because it doesn't work. This is one way to fix it that worked for me, but it might not work for you because you might have something else that is broken.


Try finding out the details of this error in the "Build Results" view where the error is shown. On the right side of the line with the error message there is an icon with several lines. This will show you some helpful details.

This way I found out for me it was a duplicate iPhone developer certificate in my keychain - one of which had been expired. Maybe search for "iphone" in your keychain (select "All Items" category first).


The real FIX for me was:
The only problem is I had my Provisioning Profile "invalid" in member center, because that old provisioning profile was generated by old certificate.
Once you regenerate your certificate, or regenerate your Provisioning Profile, make sure you download them and feed them to Xcode.


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.


Most answers will tell you that you have a duplicate certificate. This is true for my case but the answers left out how to do it.

For me, my account expired and I have to get a new certificate and install it. Next, I looked at Keychain and removes the expired certificate but still got the error. What works for me is actually searching for "iPhone" in Keychain and removing all expired certificates. Apparently, some of it are not shown in System/Certificates or login/Certificates.

Hope this helps!


This issue happened for me when I had multiple targets in one project, and I changed the CFBundleExecutable plist property to something other than the target's name.

So, for example, I had the following targets in one project:

  • SomeApp
  • SomeApp WatchKit Extension
  • SomeApp WatchKit App
  • SomeApp Today Widget
  • SomeApp for OS X (this is the target where the codesign error happens)

SomeApp for OS X had its CFBundleExecutable property set to just SomeApp, which not only conflicted with the first target called SomeApp but was different from the target it was meant for. Changing SomeApp for OS X to SomeApp and then renaming the first target worked fine for me.


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.


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


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.


Just troubleshooted this same issue. I'd created a resources folder with my icons inside, then added it to my project via right-click > Add Files > [select resources folder]. Apparently this is a bad idea.

Instead create a new group in your project (called "Resources" in my case), and then right click > add files to that and then choose the individual files. Project built immediately.


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


Some of the answers above allude to the problem but don't clearly spell out the steps to correct it.

Here is my attempt at after it has become super frustrating which seems to have worked for me so far :

The problem is caused because there is duplicate certificates in your Apple Developer portal or potentially in your machine. I haven't had any negative consequences from doing this and its worked so far.

  1. Close Xcode!

  2. You have to remove the existing certs from your developer account visit : https://developer.apple.com/account/ios/certificate/development/ and select development account ( there should be multiple certs) I revoked each one by clicking on them and selecting revoke.

select development certs

2.remove certs from your keychain on your Mac

  • Open Keychain app by pressing clover+space and typing in keychaing
    and pressing enter
  • Search in the top right hand corner for "developer"
  • Select the potential duplicate keys and export/delete them so they aren't in the list.

search by developer

  1. Lastly regenerate your certs in XCode and rebooot

    • Reopen xcode
    • regenerate a new cert by going to project -> General --> Signing
    • reselect your "Team Account"

signing setup

  • a new cert should be generated
  • Reboot for good measure - and enjoy being free from this bug ( which Apple should really sort out, if it was at all possible to replicate easily)

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


One solution more works with me, If you installed two versions of XCode and you install the second without uninstalling the first in the same directory (/Developer/), you did it wrong. So the solution that works for me was:

1 - Uninstall the current Xcode version with the command sudo /Developer/Library/uninstall-devtools --mode=all.

2 - Install the first Xcode version you had first.

3 - Again sudo /Developer/Library/uninstall-devtools --mode=all.

4 - Then, all is clean and you are able to install the version you want.

More things: maybe you need to restart the computer after install the Xcode or even (in some cases) install two times the Xcode.

I hope I works it take me a lot of time to know that, good luck!!!


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.


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.


For me I had code coverage enabled on the scheme of a framework rather than it's corresponding test scheme. Disabling the code coverage sorted the problem.


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


Here is how I solved the same problem. It may help someone.

I deleted the Development Provisionning Profile (that I was using) from the server, then created one with a slightly different name. I used it and it worked.


A very simple answer to this very-complicated question. It involves no knowledge of code-signing and everything connected with it.

Take an old app that is not needed any more. Make sure it works, then replace its code with that of the new app having the code-signing error. The old app should now work fine, accomplishing what you wanted with the new app.

Only down side: the working app has the title of the old one.


If you're using phonegap/cordova:

I got this when building from Cordova but the solution for me was much simpler. A permissions issue.

Just set the files to correct permissions

chmod -R 774 ./projectfolder

And then set ownership

chown -R youraccname:staff ./projectfolder 

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.


After hours of googling and trying out different things, this is what fixed it for me:

  1. Make sure there are no certificates in the System > Certificates tab on Keychain Access. Remove all duplicate certificates from there.

  2. Install the WWDR intermediate certificate under certificates from the provisioning portal, in addition to the developers certificates and make sure you see it in the Login > Certificates tab on Keychain Access.


For me, I just updated to Xcode 8, and converted my Swift 2.2 code to Swift 3 code, and I got errors in the Unit Testing and UI Testing. I just cleaned and then all the errors disappeared.


Following steps worked for me

  • Cleaned my device from all provision profiles
  • Cleaned OSx Keychain from my Dev iOS Certificates & Keys
  • From Apple Developer Program regenerated Certificate / Provisioning profile
  • Installed Provisioning profile into my Xcode project
  • Fixed Team issues in Project Target
  • Configured appropriate Code Signing Identity in Project/Target/Build Settings

Examples related to ios

Adding a UISegmentedControl to UITableView Crop image to specified size and picture location Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Keep placeholder text in UITextField on input in IOS Accessing AppDelegate from framework? Autoresize View When SubViews are Added Warp \ bend effect on a UIView? Speech input for visually impaired users without the need to tap the screen make UITableViewCell selectable only while editing Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

Examples related to iphone

Detect if the device is iPhone X Xcode 8 shows error that provisioning profile doesn't include signing certificate Access files in /var/mobile/Containers/Data/Application without jailbreaking iPhone Certificate has either expired or has been revoked Missing Compliance in Status when I add built for internal testing in Test Flight.How to solve? cordova run with ios error .. Error code 65 for command: xcodebuild with args: "Could not find Developer Disk Image" Reason: no suitable image found iPad Multitasking support requires these orientations How to insert new cell into UITableView in Swift

Examples related to exit-code

What is a thread exit code? check if command was successful in a batch file Difference between exit(0) and exit(1) in Python Check if process returns 0 with batch file Command /usr/bin/codesign failed with exit code 1 In a Bash script, how can I exit the entire script if a certain condition occurs? Are there any standard exit status codes in Linux? How do I get the application exit code from a Windows command line? Exit codes in Python How do I specify the exit code of a console application in .NET?

Examples related to codesign

Codesign wants to access key "access" in your keychain, I put in my login password but keeps asking me command/usr/bin/codesign failed with exit code 1- code sign error missing private key in the distribution certificate on keychain Re-sign IPA (iPhone) Command /usr/bin/codesign failed with exit code 1 Codesign error: Provisioning profile cannot be found after deleting expired profile