English 中文(简体)
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?

问题回答

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.

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.

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.

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

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

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.

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.

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.

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.

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 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.

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.

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.

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!

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.

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 

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)

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.

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).

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!!!

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

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

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.

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.

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.

For me the problem was HTTP proxy

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.

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.

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.

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.





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签