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