问题
I'm currently in the process of submitting my first app to the Apple store. I've completed the following processes
- Obtained a developer account
- Logged into the Member Center to Create an App ID
- Used keychain access to request and receive a distribution certificate
- 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?
回答1:
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:
- Xcode Perferences (CMD + ,)
- Accounts
- Select your account on the left
- Select view details on the bottom right
- Refresh (using the small button on the bottom left)

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:
- select the target (not project) you want to build in Xcode
- switch to build settings
- look for the "Code Signing" section
- check if the correct profile is selected under "Provisioning Profile" => "Release"

Next, check your Scheme Settings:
- select Product menu
- open scheme submenu
- select edit scheme...
- select "Archive" on the left
- Build configuration should be set to "Release"

Next, check the Keychain Access Trust
settings:
- open keychain access (spotlight => keychain)
- select login
- click on Certificates
- look for
iPhone Distribution: Elena Carrasco (8HE2MJLM25)
on the right - right click, select "Get Info"
- open "Trust" section
- set to "Use System Defaults"
- repeat steps 5 to 7 for
Apple Worldwide Developer Relations Certificate Authority

Next, check the Keychain Access private key Access Control
:
- repeat steps 1 to 4 from previous check
- expand the profile to make your private key visible
- right click on the private key, select "Get Info"
- switch to "Access Control"
- select "Confirm before allowing access"
- use the "+" button to add "codesign" (normally located in
/usr/bin/codesign
)
Hint: if it doesn't show up in the file browser, usecmd + shift + g
to enter the path manually - when using Carthage: add
/usr/bin/productbuild
here as well (thx to DesignatedNerd) - "Save Changes"
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/
回答2:
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.
- Open keychain access.
- Lock the 'login' keychain.
- Unlock it.
Clean and build after doing the above steps and everything works fine now.
回答3:
For me following steps worked:
- Quit
Xcode
. - Open
Terminal
. - Typed Command
xattr -rc /Users/manabkumarmal/Desktop/Projects/MyProjectHome
- Open Xcode.
- Cleaned.
- Now worked and No Error.
回答4:
This worked for me. Give it a try:
cd ~/Library/Developer/Xcode/DerivedData
xattr -rc .
回答5:
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 *
回答6:
For me "Restarting Mac System" got worked
回答7:
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.
回答8:
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.
- quit xcode.
- open Keychain Access.
- in the 'Certificates' section, go through all "iPhone Distribution" certificates and if they're expired or revoked or otherwise invalid, delete them.
- same as 3, but for the 'My Certificates' section.
- re-open xcode and try again.
回答9:
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.
回答10:
I have solved this problem, very easily.
- Just reboot the computer ( it refreshes everything by itself ).
I hope this helps..
回答11:
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.
回答12:
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.
回答13:
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.
回答14:
Remove the existing precompiled files:
rm -rf /Users/raghu/Library/Developer/Xcode/DerivedData/Solitare-fdaukpanamlzllacxvdzfbeqcrsg/
And try to build it again.
回答15:
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.
回答16:
delete your certificate in your dev then Reinstall and it will working!
回答17:
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.
回答18:
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!
回答19:
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.
回答20:
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.
回答21:
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:
- Goto Apple Developer Portal and revoke your old (not working) development certificate.
- Add iOS App Development Certificate
- Follow the step on from Apple
- Download the newly generated certificate and add it (double click) to your Keychain
- Make sure it is in your XCode Accounts
Then it works!
Hope it helps!
回答22:
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:
回答23:
The easy way (which will do all png files) I used:
Run This Command in Terminal
find . -name "*.png" -exec xattr -c {} \;
来源:https://stackoverflow.com/questions/29242485/command-usr-bin-codesign-failed-with-exit-code-1-code-sign-error