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

IosObjective CXcodeCodesignXcode Archive

Ios Problem Overview


I'm currently in the process of submitting my first app to the Apple store. I've completed the following processes

  1. Obtained a developer account
  2. Logged into the Member Center to Create an App ID
  3. Used keychain access to request and receive a distribution certificate
  4. Obtained a provisioning profile using my id and certificate

When I build the app it runs perfectly in the app simulator and on the actual ipad, however when I switch my app to Archive on iOS Device i have a major code sign error which i've attached below.

codesign /Users/Gaby/Library/Developer/Xcode/DerivedData/RoyalAppInspection-dthvtpxadkslqmhkwdpaqkyujscg/Build/Products/Debug-iphoneos/RoyalAppInspection.app
cd /Users/Gaby/Desktop/RoyalAppInspection
export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin


/usr/bin/codesign --force --sign 79640A11C8D22589BD337496ABB8443581513846 --entitlements /Users/Gaby/Library/Developer/Xcode/DerivedData/RoyalAppInspection-dthvtpxadkslqmhkwdpaqkyujscg/Build/Intermediates/RoyalAppInspection.build/Debug-iphoneos/RoyalAppInspection.build/RoyalAppInspection.app.xcent /Users/Gaby/Library/Developer/Xcode/DerivedData/RoyalAppInspection-dthvtpxadkslqmhkwdpaqkyujscg/Build/Products/Debug-iphoneos/RoyalAppInspection.app

79640A11C8D22589BD337496ABB8443581513846: no identity found Command /usr/bin/codesign failed with exit code 1

I have no idea what to do to fix this, as I've tried to make sure all the other aspects of the process were completed correctly.

One concern i did have was when i clicked the provisioning profile file it would not open and "add to library" wouldn't pop up (i cannot access iphone configuration utility for some reason.) I manually added the .mobileprovision file to my xcode project but i'm thinking this may also be a source of my error.

Anyone, can you please help?

Ios Solutions


Solution 1 - Ios

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.

Solution 2 - Ios

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/

Solution 3 - Ios

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.

Solution 4 - Ios

This worked for me. Give it a try:

cd ~/Library/Developer/Xcode/DerivedData
xattr -rc .

Solution 5 - Ios

I had this error in Xcode 8 and Mac OS Sierra. Tried all the above solutions and none worked. This was the only one that worked for me. Open terminal, and type this in:

cd ~/Library/Developer/Xcode/DerivedData
xattr -c *

Solution 6 - Ios

For me "Restarting Mac System" got worked

Solution 7 - Ios

For me, i just cleaned the app and it worked (cmd + shift + k), removing the error. I got the error after updating to swift 2.3.

Solution 8 - Ios

Another reason you may see this error that I haven't seen posted yet, especially if you are using Jenkins, is that your certificate's private key needs "Allow all applications to access this item" selected.

  1. Open your Mac keychain
  2. Go to "Certificates" or "My Certificates" under "Category" on the left.
  3. Find the cert you're trying to sign with, and click the little grey triangle on the left of the certificate to reveal the associated private key.
  4. Left/ double-click the private key and select "Get Info."
  5. Toggle from "Attributes" to "Access control"
  6. Select "Allow all applications to access this item" and save changes.
    enter image description here I maintain a large cluster of Mac mini nodes as part of a centralized Jenkins CI system, and this can come up.

Solution 9 - Ios

Do everything d4Rk suggests, that is a great walk-through. if it still isn't signing, you might have some expired or revoked certificates. I find this can happen when you're working on a team.

  1. quit xcode.

  2. open Keychain Access.

  3. in the 'Certificates' section, go through all "iPhone Distribution" certificates and if they're expired or revoked or otherwise invalid, delete them.

  4. same as 3, but for the 'My Certificates' section.

  5. re-open xcode and try again.

Solution 10 - Ios

Open the project into the Xcode.
Select project.app file and right click on it, select “show in finder” option.
Open terminal and go to the project.app file path.

Type the following to commands one by one:

xattr -lr project.app
xattr -cr project.app

Open the project and run.

Solution 11 - Ios

I Followed all the things mentioned in this thread but still facing same issue-

/usr/bin/codesign --force --sign A7F8FCD694D7923A3E57826398C3380E2E5A5446 --entitlements  unknown error -1=ffffffffffffffff
Command /usr/bin/codesign failed with exit code 1

I have configured Automatic signing with my code base which will work with xcode run as well as xcodebuild run from terminal from my machine but it gives above error when I run it on jenkins pipeline or try to run on terminal from remotely connected machine

In my case Automatic signing is not working if access remotely. because I need to open keychain before archive using

security unlock-keychain -p "newpassword" "/Users/xyz/Library/Keychains/login.keychain"

keychain passwords & login password for macOS X user was different I change it to new same password and it works for me.

Solution 12 - Ios

I have solved this problem, very easily.

  • Just reboot the computer ( it refreshes everything by itself ).

I hope this helps..

Solution 13 - Ios

Reboot also worked for me. Interestingly it seems to be an issue with allowing Xcode access to the certificates. When i tried the archive again, i received 2 popups asking me if i wanted to allow Xcode to access my keychain. After this it worked fine.

Solution 14 - Ios

Just reset your development and distribution certificate and clean your project. After that , Reboot also worked for me. Interestingly it seems to be an issue with allowing Xcode access to the certificates. When i tried the archive again, i received 2 popups asking me if i wanted to allow Xcode to access my keychain. After this it worked fine.

Solution 15 - Ios

Remove the existing precompiled files:

rm -rf  /Users/raghu/Library/Developer/Xcode/DerivedData/Solitare-fdaukpanamlzllacxvdzfbeqcrsg/

And try to build it again.

Solution 16 - Ios

Rebooting didn't work for me.

Just try with downloading and adding the Certificate again to keyChain. That worked for me. When I checked Keychain Access the respective certificate was missing. Got the problem solve when I reinstalled the certificate.

Solution 17 - Ios

delete your certificate in your dev then Reinstall and it will working!

Solution 18 - Ios

I have Solved This Problem. If your project has .xcdatamodeld file (mean you are using coreData) then make sure the entities you formed go its Data Model Inspector and check Class has codegen, manual/None or classdefination. if it is class defination then make it manual/None and clean the project and run again. screenshots are given below:

enter image description here

enter image description here

Solution 19 - Ios

If nothing is working in @d4Rk solution Just use the below screen to delete unwanted/expired similar provision profiles. Right click on provision profile to move it to trash. provision profile window

Because in my case after doing all the steps I was still getting the same issue and it resolved when I deleted old expired provision profiles with same name and then using the correct one in build setting.

Solution 20 - Ios

In my situation, some pods were out of date after I updated my OS. Here's what fixed it:

In terminal:

cd /Users/quaisafzali/Desktop/AppFolder/Application/
pod install

Then, open your project in Xcode and Clean it (Cmd+Shift+K), then Build/Run.

This worked for me, hope it helps some of you!

Solution 21 - Ios

I had the same error on January 2018 with xcode 8.2.1

Before I try to open xcode I couldn't because the system was updating. I tried sometime later and it let me working on it, and then I got the same error.

I followed most of the solutions described in this article but they didn't work for me.

Then I remembered the message about the system updating and I tried to reboot the machine.

And that did the magic. It worked for me.

Solution 22 - Ios

Rebooting worked for me too. After upgrading to High Sierra I got tons of problems with password and it looks like I needed to enter the Password for the Keychain access to XCode.

Solution 23 - Ios

I recently had this issue and all above solutions didn't work for me.

The reason why it works on your simulator but not real devices is probably related to your Development Certificate.

So I revoked my certificate on Apple Developer Portal and request a new one on my computer. Here are the steps:

  1. Goto Apple Developer Portal and revoke your old (not working) development certificate. revoke
  2. Add iOS App Development Certificate add
  3. Follow the step on from Apple
  4. Download the newly generated certificate and add it (double click) to your Keychain download
  5. Make sure it is in your XCode Accounts accounts

Then it works!

Hope it helps!

Solution 24 - Ios

I was having the issue after select the deny when it asks for permission

After some search I got it fixed by restarting the system.

Solution 25 - Ios

Today, 2020 year, I've solved this problem with Xcode 11.7, Xcode 12.0 and Xcode 12.1 following these steps:

Identifying the bad certificate:

  • From you Keychains select Login
  • From Category select Certificates
  • Find any Apple Certificate that has the blue +
  • Double click on the certificate.
  • Expand the Trust

If it's messed up then the "When using this certificate" is set to "Always Trust" along with the blue +

Fixing the bad certificate:

  • Just set it to "Use System Defaults" and close it.
  • You'll get a pop up. Type in your password to update settings.
  • Close KeyChain.
  • Go back to your project, clean and run.

Problem should have gone away. If that didn't work then go back to Keychain and just double check and see if there are any other Apple certificates that are set to Always Trust and repeat the process.

Solution 26 - Ios

The easy way (which will do all png files) I used:

Run This Command in Terminal

find . -name "*.png" -exec xattr -c {} \;

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLeleMarieCView Question on Stackoverflow
Solution 1 - IosSAPLogixView Answer on Stackoverflow
Solution 2 - Iosd4RkView Answer on Stackoverflow
Solution 3 - IosManab Kumar MalView Answer on Stackoverflow
Solution 4 - IosShreeView Answer on Stackoverflow
Solution 5 - IosHedyloveView Answer on Stackoverflow
Solution 6 - IosSakthimuthiahView Answer on Stackoverflow
Solution 7 - IoslukeView Answer on Stackoverflow
Solution 8 - IosLizCiraGView Answer on Stackoverflow
Solution 9 - Iosorion elenzilView Answer on Stackoverflow
Solution 10 - IosMujahed AnsariView Answer on Stackoverflow
Solution 11 - IosPiyushView Answer on Stackoverflow
Solution 12 - IosLazyXView Answer on Stackoverflow
Solution 13 - IosMikeView Answer on Stackoverflow
Solution 14 - IosRuchin SomalView Answer on Stackoverflow
Solution 15 - IosRaghu MRView Answer on Stackoverflow
Solution 16 - Iosgeet SebastianView Answer on Stackoverflow
Solution 17 - IosozzbmtView Answer on Stackoverflow
Solution 18 - IosMRizwan33View Answer on Stackoverflow
Solution 19 - IosAdnan HaiderView Answer on Stackoverflow
Solution 20 - IosQ AView Answer on Stackoverflow
Solution 21 - IosIker EtxebarriaView Answer on Stackoverflow
Solution 22 - IosPierre TanguayView Answer on Stackoverflow
Solution 23 - IosnigongView Answer on Stackoverflow
Solution 24 - IosZeeshan AnsariView Answer on Stackoverflow
Solution 25 - IosAlessandro OrnanoView Answer on Stackoverflow
Solution 26 - IosUmarView Answer on Stackoverflow