command/usr/bin/codesign failed with exit code 1- code sign error command/usr/bin/codesign failed with exit code 1- code sign error xcode xcode

command/usr/bin/codesign failed with exit code 1- code sign error


The following steps solved the problem for me. I was having the issue where it was not compiling for the device or archiving, working fine for simulator.

  1. Open keychain access.
  2. Lock the 'login' keychain.
  3. Unlock it.

Clean and build after doing the above steps and everything works fine now.


You almost made it on your own, but in the end there seems to be something wrong with your profile.

First I would recommend a tool to "look inside" the profile to make sure it's the right one: http://furbo.org/2013/11/02/a-quick-look-plug-in-for-provisioning/

This will just add some more information about the profile, when selecting it in Finder and pressing space (Quick Look).


Check your Xcode Preferences:

  1. Xcode Perferences (CMD + ,)
  2. Accounts
  3. Select your account on the left
  4. Select view details on the bottom right
  5. Refresh (using the small button on the bottom left)

Xcode Settings

Xcode stores the profiles in ~/Library/MobileDevice/Provisioning Profiles

If your distribution profile is not in there, double click on it.

Then it should appear in that folder, but with a hashed name, e.g. 1edf8f42-fd1c-48a9-8938-754cdf6f7f41.mobileprovision at this point the Quick Look plugin comes in handy :-)


Next, check your Project Settings:

  1. select the target (not project) you want to build in Xcode
  2. switch to build settings
  3. look for the "Code Signing" section
  4. check if the correct profile is selected under "Provisioning Profile" => "Release"

Build Settings


Next, check your Scheme Settings:

  1. select Product menu
  2. open scheme submenu
  3. select edit scheme...
  4. select "Archive" on the left
  5. Build configuration should be set to "Release"

Scheme Settings


Next, check the Keychain Access Trust settings:

  1. open keychain access (spotlight => keychain)
  2. select login
  3. click on Certificates
  4. look for iPhone Distribution: Elena Carrasco (8HE2MJLM25) on the right
  5. right click, select "Get Info"
  6. open "Trust" section
  7. set to "Use System Defaults"
  8. repeat steps 5 to 7 for Apple Worldwide Developer Relations Certificate Authority

Keychain


Next, check the Keychain Access private key Access Control:

  1. repeat steps 1 to 4 from previous check
  2. expand the profile to make your private key visible
  3. right click on the private key, select "Get Info"
  4. switch to "Access Control"
  5. select "Confirm before allowing access"
  6. use the "+" button to add "codesign" (normally located in /usr/bin/codesign)
    Hint: if it doesn't show up in the file browser, use cmd + shift + g to enter the path manually
  7. when using Carthage: add /usr/bin/productbuild here as well (thx to DesignatedNerd)
  8. "Save Changes"

Keychain 2

Hope one of this does trick for you!


Update (4/22/16):

I just found a very nice explanation about the whole code sign process (it's really worth reading):https://www.objc.io/issues/17-security/inside-code-signing/


For me following steps worked:

  1. Quit Xcode.
  2. Open Terminal.
  3. Typed Command xattr -rc /Users/manabkumarmal/Desktop/Projects/MyProjectHome
  4. Open Xcode.
  5. Cleaned.
  6. Now worked and No Error.