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

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?

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.

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, use cmd + 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/

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.

This worked for me. Give it a try:
cd ~/Library/Developer/Xcode/DerivedData
xattr -rc .

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 *

For me "Restarting Mac System" got worked

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.

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.
Open your Mac keychain
Go to "Certificates" or "My Certificates" under "Category" on the left.
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.
Left/ double-click the private key and select "Get Info."
Toggle from "Attributes" to "Access control"
Select "Allow all applications to access this item" and save changes.
I maintain a large cluster of Mac mini nodes as part of a centralized Jenkins CI system, and this can come up.

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.

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.

I have solved this problem, very easily.
Just reboot the computer ( it refreshes everything by itself ).
I hope this helps..

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.

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.

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.

Remove the existing precompiled files:
rm -rf /Users/raghu/Library/Developer/Xcode/DerivedData/Solitare-fdaukpanamlzllacxvdzfbeqcrsg/
And try to build it again.

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.

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

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.

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!

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.

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.

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!

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:

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.

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.

The easy way (which will do all png files) I used:
Run This Command in Terminal
find . -name "*.png" -exec xattr -c {} \;

Related

Unity Xcode Build "Automatic signing is unable to resolve an issue" [duplicate]

This post relates to a rapidly changing event.
I've tried all the other questions and searched everything on this that I could already, a lot of the other questions involved existing apps that were being updated or people with developer accounts but this is like my second time using Xcode and it has worked before.
This just happened out of nowhere. I keep getting these two errors and it allows me to run simulators but not build onto my iPhone:
Automatic signing is unable to resolve an issue with the "LearningSpriteKit" target's entitlements.
Automatic signing can't add the application-identifier and keychain-access-groups entitlements to your provisioning profile. Switch to manual signing and resolve the issue by downloading a matching provisioning profile from the developer website. Alternatively, to continue using automatic signing, remove these entitlements from your entitlements file and their associated functionality from your code.
Provisioning profile "iOS Team Provisioning Profile: #####.LearningSpriteKit" doesn't include the application-identifier and keychain-access-groups entitlements.
This issue is related to Bug 1534145. SSL.com: P-384 curve / ecdsa-with-SHA256 certificates.
A representative from Apple estimated 558,000 certificates to become invalidated: Bug 1533655. DigiCert: Apple: Non-compliant Serial Numbers
GoDaddy, Google, Apple and Facebook (that would explain why Facebook was glitchy today) are affected.
They are working on resolving the issue right now.
That would explain our problems, folks!
Update: The issue has been resolved. Try to refresh your projects.
Workaround: change Bundle Identifier and/or Version.
I restored a profile from Time Machine when this was working and upon launch, Xcode immediately deletes and replaces it with a new one. The key difference seems to be the old profile has the get-task-allow entitlement while the new one has NO entitlements. This is definitely broken at Apple's end.
Edit: The entitlements should also include a keychain access group, but again, no entitlements at all. Should look like:
It seems Apple broke the automatic signing system.
I was playing around with a few projects and Xcode just fetches the incorrect profile.
This worked for me:
Turn off "Automatically manage signing" in project target
Go to ~/Library⁩/⁨MobileDevice⁩/⁨Provisioning Profiles⁩
Remove previously downloaded profiles
Turn on "Automatically manage signing" again
EDIT
As per latest update Apple successfully resolved Automatically Code
Sign with Free Account issue.
I tried it and I can confirm its resolved.
Please try at your end.
Update
Tested with Latest XCode 10.2 and it's working fine + they improved
performance of overall Xcode & codesign feature.
I am also facing the same issue while I am creating a new Profile from Xcode and if I go to other projects and check over there also I am facing the same issue as below.
Due to this issue, none of my projects can build with the old profile and certificate.
The strange issue, so I checked a newly created Profile and compared with the old one, and I found that App ID is unknown as well as there were no Entitlement details in the newly created profile.
Check the below screenshots of the old and new profile comparison:
Old Profile:
New Profile:
So it means it's not able to set App Id and Entitlements in the new profile. So the end result does not work all old profiles and giving the same error in all projects.
Issue Workaround:
Step1: Go to Provisioning Profile folder (path: ~⁨Library⁩ ▸ ⁨MobileDevice⁩ ▸ ⁨Provisioning Profiles⁩).
Or use a shortcut to jump directly into this folder like CMD + Shift + G and enter ~/Library/MobileDevice/Provisioning Profiles it will redirect your finder directly on the Provisioning Profiles folder.
Step2: Sort the files inside that folder by Date Modified.
Step3: Check profile with Unknown App Id and delete all unknown profiles.
Step4: Come back on Xcode and check all old projects will work as expected.
Note: Make sure none of your project open while doing above changes.
Otherwise, it will create a new profile with Unknown App Id.
I hope this will help and Apple will solve this bug soon!
UPDATE: This solution still works as on 2019/Mar/20 7:00 UTC+0
SOLUTION: no Xcode reinstallation is required. I used a brand new free AppleId, but later checked with my old AppleID and it also works.
In Xcode, under the General tab, untick the Automatically manage signing option
Close Xcode.
Erase old profiles in ~/Library/MobileDevice/Provisioning Profiles:
cd ~/Library/MobileDevice/Provisioning\ Profiles
rm -rf *
On MacOS, run Launchpad → Other → Keychain Access and remove all certificates related to iPhone development, like the following four on the picture:
Apple Worldwide Developer Relations Certification Authority
Developer ID Certification Authority
iPhone Developer: your_name_or_email
Uninstall the old app on iPhone. Restart both iPhone and Mac
Open Xcode and change the Bundle Identifier of your app, at least one character (later you may revert this change)
Enable the Automatically manage signing option in Xcode.
After this you should be able to run and debug your app on your device.
If you have a “iPhone has denied the launch request” problem, the solution is in an answer to Stack Overflow question iOS 12 iPad Denied Launch Request - Xcode.
In short, you need in Xcode to go to menu Product → Scheme → Edit Scheme... and select Executable: ask on launch.
This issue has been resolved, BUT some people still have a problem with it. If you're one of them, try the following:
1. In the General tab of target settings - uncheck the Automatically manage signing option
2. Close Xcode (fully, not just your project)
3. Erase .mobileprovision files under ~/Library/MobileDevice/Provisioning Profiles/
4. In Keychain Access, delete the following:
iPhone Developer: youremail#email.com
Developer ID Certification Authority
Apple Worldwide Developer Relations Certification Authority 3.
5. Delete the app on your iOS devices
6. Restart your Mac and iOS devices
7. Open Xcode again
8. Change the Bundle Identifier (even if it's a single character, you'd change it back to the original after you get it going)
9. Check the Automatically manage signing option
10. Use USB to connect your iPhone/iPad.
11. Make sure you trust your certificate on your iOS devices
This should do work for you.
It seems that this problem has been resolved now and the personal accounts can resign their apps automatically again.
Regarding to #Paul answer, it is not related to uninstalling Xcode. It is fixed from the server side.
The only thing that is required is removing Apple Developer Certificate (for the personal account) from your keychain, so that Xcode retries to generate and download a new one.
Here is the solution:
Let Xcode be open.
Select your developer account and let the error appear again.
Go to the keychain app
4.a) Goto certificate section
4.b) Remove All (valid and invalids) certificates (I have three valid and many invalid!)
After removing the last certificate, macOS will recreate a new certificate for the active developer account automatically.
Run your app in your iDevice. You need to enter your system password to add newly created certificate into the Keychain.
If in the second run it says
Your iPhone has denied the launch request
Just go to:
Product → Scheme → *edit scheme: uncheck "Debug executable"
I hope it solves your problem.
I got it to work by doing the following steps:
Go to Xcode
Preferences
Accounts
Manage certificates
Plus sign
iOS Development
Done
Download manual Profiles
Close
Go to your target
Change development team to none
Change development team to your previous team
It should work.
I am finally able to deploy to our iOS devices again. Here are the steps I took to make it work.
First, I followed all 10 steps in Zameer's answer here. I have copied them below:
Open your project in XCode.
Select your project from the project navigator and then select your target from the column.
Click on the General tab and under the Signing section, make sure "Automatically manage signing" is enabled.
Click on the Capabilities tab and turn On both the "App Groups" and "Keychain Sharing" settings. This might raise an
"Automatic signing failed" popup error, just click cancel to make it go away.
This should generate a entitlements file for you named nameProject.entitlements in the project folder of your project navigator.
Move this entitlements file outside of the folder, just below your project file.
Select your target again and return to the Capabilities tab to turn Off both the "App Groups" and "Keychain Sharing"
settings. This again might raise an "Automatic signing failed" popup
error, just click cancel to make it go away.
Now select your project above the target and go to Building Settings tab.
Scroll down to the Code Signing Identity setting under the Signing header and select iOS Developer from each drop down.
Under the above Signing header, double click the text field beside the Code Signing Entitlements and enter the name of your
entitlements file, nameProject.entitlements.
After completing those 10 steps, the 2 red entitlement error messages in XCode went away and I was able to build and deploy the XCode test app to the iPhone and run it.
Although that XCode test app could build and deploy, I develop on a PC using Xamarin and I was unable to deploy my Xamarin.iOS application to my iOS devices and kept getting an error in Visual Studio: the executable was signed with invalid entitlements. I did the following things and now I can deploy my Xamarin app and run it on my iOS devices:
I deleted the provisioning profile from the Mac in the ~/Library/MobileDevice/Provisioning Profiles directory. XCode immediately generated a new provisioining profile (I'm not sure if this step was necessary but I'm just writing it because that's what I did).
I changed my Xamarin.iOS.csproj file and removed Entitlements.plist from the CodesignEntitlements element so it now just looks like <CodesignEntitlements></CodesignEntitlements>. Visual Studio automatically added two elements to the same propertygroup in the project which are probably not necessary but I thought I'd mention: <CodesignExtraArgs /> and <CodesignResourceRules />.
Maybe forum post [iOS 12 SDK] - deadline March 2019 - Legacy Mode might help.
It talks about Apple refusing to build iOS applications under SDK 12 as of March 2019 (OP from Dec 2018).
I've not yet tried this, but it may be linked to the issue. I have a free developer account and am also experiencing this bug.
Here's a screenshot in case the link changes (screenshot 1 below).
This is the link from the first screenshot (screenshot 2 below)
1
2
There is one other potential source of this error. If you do not have a valid signed development certificate setup within your Xcode environment it will throw similar errors as posted by the OP.
You can check out your development certificates status following the Apple link here.
For macOS Big Sur Beta
Archive in Xcode 11
Upload with Xcode 12 beta organizer (Window -> Organizer)
For me, it finally works again. Either they just fixed it or any of my other steps helped:
Uninstall Xcode and all related files (using AppCleaner)
Install Xcode via the App Store
Change the Bundle Identifier of the App
Remove all "iOS Developer" Keys from Keychain
Here is a temporary workaround:
Change Bundle Identifier: Target → General → Identity → Bundle Identifier (set this to a different value than it is right now)
Change Version: Target → General → Identity → Version
Disable debug executable: Product → Scheme → Edit Scheme (uncheck the box that says "debug executable")
Delete Provisioning Profiles: ~/Library/MobileDevice/Provisioning Profiles delete everything in this folder.
You now should be able to build and run projects on simulators and devices.

(0xE8008018): The identity used to sign the executable is no longer valid

I'm trying to debug my app on Xcode and I'm having the following error:
The identity used to sign the executable is no longer valid.
Please verify that your device’s clock is properly set, and that your signing certificate is not expired.
(0xE8008018).
Now I know there are many questions regarding this issue, and I have tried every possible way to solve it, what I have tried so far (didn't work):
Some suggested to restart Xcode.
Refreshing the account.
Deleting all the certificates from the keychain.
Revoking all the certificates from the member center.
Installing the certificates manually.
Checked my Devices clocks (obviously)
Removed Xcode (disparately) and re-installed it.
Checking my project Build config, and made sure that the developer account is selected.
Checked my account expiration date (it's renewed 5 days ago)
Checked if I have to accept some Conditions and Terms (none)
Disabled the devices I have in the Member profile
Tested on multiple iPhones (same result)
Checked out a git tag/branch which is stable (I thought the project might be corrupted also disparately)
My concern is that it might be a temporary issue from apple, or a bug in Xcode, although it was working hours ago on my iMac, when I switched to the MacBook Pro I had this issue (and I always do this with no problems at all).
Running:
OSX Yosemite 10.10.4 (14E46)
Xcode 6.4
Trying to remove and re-add your apple id, it works for me.
xcode: Preferences...
Accounts
Select your apple account
Remove that (-)
Add again your apple account (+)
Run yor app!
After hours of investigating, the shell script for signing the project was failing at some point, without reporting back to Xcode.
I noticed that in the DerivedData folder (found in /Users/yourUsername/Library/Developer/Xcode/DerivedData/) of Xcode there were two folders with the same name of my project ending with a different hash, for example:
ProjectName--dcakkvkdhqvxstehdiuzwbpsmdal
ProjectName--kurbctkdhqvxuytrwnczwbpsmdal
I closed Xcode, and made sure to delete both folders, somehow Xcode generated two different folders for the project at some point, restarting Xcode after the deletion of the folders fixed this.
I have experienced the same situation.
But it was cleared by deleting and downloading again the provisioning profiles on my mac.
The location of the provisioning profiles is:
/Users/yourUsername/Library/MobileDevice/Provisioning Profiles/
I had the same issue. What helped me:
Set Profile to a wrong one (other project)
Run project and received the popup with information that provision profile is wrong and proposal to Fix the issue
Press Fix the issue
Just login to your developer account and create new developer certificate or revoke older one an create new. It will resolve the issue.
A Solution that might help some People
Go to developer.apple.com
go to the identities/certificates page
then click on Provisioning Profiles If you found few invalid
profiles just edit them
Make sure you check your main profile.
Click generate and close.
Now in XCode, remove your profile Add it again.
You're good to go
This will happen if you changed your Primary Email
Delete files and folders from:
~/Library/MobileDevice/Provisioning Profiles/
~/Library/Developer/Xcode/DerivedData/
The only solution for this problem is to delete the folder from
~/Library/Developer/Xcode/DerivedData/YourAppName-
This way everything will get back to normal !
Cheers !
All of the answers helped a lot but in my case developer certificate got expired that's i was getting this error while building the app.
Keychain -> Login -> My Certificates
So just removed the certificate and created new one worked fine for me.
NONE of this worked for me
vomako 's answer at The identity used to sign the executable is no longer valid
DID work -
i.e.
"Solution within Xcode:
In Xcode, go to Preferences --> Accounts --> View Details
Press the refresh button in the lower left corner (called Download all in Xcode 7)"
end of his post
It's a little refresh symbol now (circling arrow)
Then click on the Request button
Hope this saves somebody some time
I have solved the same problem. Just from "https://developer.apple.com/account/ios/profile/production/create" re-created the new Provisioning Profiles. Then download and install the new Provisioning Profiles of (Development and Distribution).

Code Sign error: No unexpired provisioning profiles found that contain any of the keychain's signing certificates

I think I've reached the nadir of iOS provisioning hell. After migrating to a new mac and doing an archive for distribution, I received the error:
Code Sign error: No unexpired provisioning profiles found that contain
any of the keychain's signing certificates
I then erased all certs and keys and provision profiles and did a "hard reset" (deleting all keys, certs, and profiles), following Apple's instructions by hand, with the same error. Then I did another hard reset and then had Xcode handle the whole thing via the Organizer, did another archive - only to see the same error.
I have all certs (WDRCA, Developer ID Cert Authority, iPhone Dev, iPhone Distribution) showing in Keychain Access, Xcode shows that it sees the dev and distribution certs, as well as the provisioning profiles, all marked with a green checkmark and "valid" status.
Code signing within the app show the correct dev and distribution is selected.
What's really troubling is that a Google search on the error shows one tech note from Apple that isn't very helpful, 2 tweets, and 3 results in Japanese - and nothing else. I contacted one of the tweeps and he said he fixed it with a hard result, which I have done twice.
Any ideas on where to go or what to do next?
Fixed it by Organizer -> Teams (select Your Team) -> Refresh (low right corner).
After removing all devices/profiles/certificates and adding/creating it did still not work here too....also removing the Xcode prefs did not help.
but it seems to in the project settings, check in the build settings under CODE_SIGN_IDENTITIY, in my project the first line was set to a old profile but not visible in the list, only if you open the pulldown, after removing that it worked.
I just had this problem as well. I finally realized that the identifier is case sensitive. For example if your product name is "StackOverflow" it automatically tags the identifier with com.yourcompanyname.StackOverflow. (this of course can be changed by going to the summary of the target). The problem lies in what the app id is in the developer portal. Make sure that the identifier in the portal matches what's in Xcode.
I have the same issue here since Xcode 4.3 install (moving from /Developer to /Applications). I found this post for changing the Xcode dir
in the terminal check what path it is set to with:
/usr/bin/xcode-select -print-path
and then if it is still set to /Developer set it to /Applications:
sudo /usr/bin/xcode-select -switch /Applications
which worked for me to be able to do the update to 4.3.2 but this did not resolve the issue mentioned....so maybe it helps you.
After nine hours of hair pulling, cursing and burying my head in my hands... All I had to do was create a new project, transfer the files over by hand, and the error went away. Argh.
Update: My marking my own answer as correct does not mean these other answers were wrong - I didn't get a chance to try any of them.
i 've met the same problem.
the answer of the problem is simple.
you need to login your apple develpoer web site
to apply and download a profile for your app .
after double-click the download file ,
you can see the file in organization of the project in xcode .
the name of the bundle id is the type like com.yourname.appname
the xcode device choose the ios device
and the codesign of the target should choose distribution
which is one of the file in organization of the project in xcode .
f.y.i.
A few days ago I had exactly the same problem.
The issue is related to no having the correct distribution provisioning profiles; My error was that I added a new device to the portal and did not re-download the distribution profile from the developer site.
Today I had the same issue; while it was working perfectly with the developer profile i could not archive or build a distribution package..
I had to go to the portal and manually re-download my distribution profile because new hardware was added even though I am not actively using it on the developer profile (did not check the box to add it to the provision)
Hope it helps anyone
I went straight to "but it seems to in the project settings, check in the build settings under CODE_SIGN_IDENTITIY, in my project the first line was set to a old profile but not visible in the list, only if you open the pulldown, after removing that it worked."
And that seems to have done the trick.
I fixed it by updating the bundle identifier in the project settings > targets > appName
in the info tab.
I had this problem, and fixed it by putting my scheme back to Debug, as opposed to Release.
I faced the same problem after upgrading to Xcode 4.3.2 and SDK 5.1. Everything worked perfectly in the previously version of Xcode with SDK 5.0. After many hours of hair pulling I created a new distribution certificate in the iOS Provisioning Portal->Provisioning-> Distribution Tab and after downloading it and installing it into Xcode (drag-and-drop) it works to archive after selecting the new certificate in the Code Signing area for my target.
I had the same problem after upgrading the OS/xcode so its worth to try.
the solution for me was simple,
go to the ios provisioning portal.
make sure the app certificate for the app is valid and not expired.
download again it again and double click it to install.
it should fix the problem.
I had this error when trying to build a release version - no problem occurred for debug builds. Baffling because in the code signing section of the build settings I had the same profile selected.
The solution for me was to create and download a new distribution provisioning profile, even though from the settings it appears not to be used.
I found a solution that was not on here, after looking through the errors and looking into my raw .app file, i found the solution.
Go to your target, and then "Build Phases" instead of Build Settings.
Make sure that in "Compile Sources" is your storyboard. For some reason Xcode didn't add the storyboard to this area of my file when I coppied the storyboard in.
P.S. I had to add the other .m's that i wanted in the project to this area as well (the ones that I dragged in, not created in the project)
Hope this helps
In the Target settings, in Sumary, check if Bundle Identifier is exactly the same as in itunesconnect.com
as example:
Bundle ID: com.mycompany.myapplication
I fixed mine by Analysing instead and checking that error. It indicated that my bundle ID was not lowercase as in the provisioning profile.
I actually was having this issue but whenever I tried to get into the organiser it caused XCode to crash. To resolve this issue I went into my targets and changed everything under Code Signing Identity to iPhone Developer. The target defaulted to the provisioning profile I wanted and it worked.
What worked for me is to choose "Don't code sign" and then do a build. This generates an error, but seems to clear out whatever xcode is hanging on to. Then choose the right provisioning profile and build. This has solved similar problems for me in the past.
Fixed it.
Went to Project-> general-> found an option "no provisioning profiles found" Fix Issue button. Clicked it . Automatically fixed
Reason Of Error
If you don't have any valid provisioning profile downloaded to your system's Library/MobileDevice/Provisioning Profiles folder then you might run into this error.
Solution
Login to your Apple Developer Account from Xcode->Preferences->Accounts and then download a valid provisioning profile.
Move to Target->General and select the correct Team.
Now go to Project Build Settings->Code Signing Identity and select just 'iOS Developer' and 'Automatic' in Provisioning Profiles. Your app will run smoothly.
In the Build Settings look for
General > Identity > Bundle Identifier and Team Settings. Fill in the Bundle Identifier and select Team. (this basically your publishing info). Of course as the others have written you'll need the correct dev or team account. This solution worked for me and resolved the build error.
Its because of the SUDO permission you have given while adding the platform.
Follow this link Ionic Code Sign error: No unexpired provisioning profiles

Xcode asking username & password every time I compile to device

I use an admin account for the development. But every time I compile to a device Xcode is asking for admin username & password. I googled the issue. But none of the solutions worked. I tried the workarounds from this post, but it didn't work
Authorize a non-admin developer in Xcode / Mac OS
I also tried disabling and enabling the DevSecurityTools but it didn't work. I am using Xcode 4.3.1 installed on Mac OSX Lion 10.7.3.
Is there any way to fix this?
For solution go to Keychain Access,
and in the top left navigation, move your Developer certificate from "System" to "Login".
Actually problem is Developer certificate is under "System", and it is locked every-time, so it will require a password to unlock, whereas when certificate is in "Login" section it will resolve that.
In keychain remove your development and distribution certificates from System and place them under Login. It will ask once and you have to select Always allow
That worked for me. Hope it works for you aswel.
In Xcode 7.1, I didn't find Login so I have given access to Xcode and codesign for the certificate key by following steps:
Open Key Chain
Go to Certificate under System
Click on closure, right click on private key and select 'Get Info'
Click on 'Access Control' tab
Add Xcode and coding under 'Always allow access by these applications:'
It solves my problem.
Is the /Developers directory from the old Xcode still on the drive? I just had a user with this issue that was also experiencing build fails with code that other users were able to build successfully. Some of the file associations cause the new Xcode (moved to the /Applications folder) to reference components in the old /Developers folder. Once we removed the folder and emptied the trash, everything worked as expected.
After moving Developers certificate form "System" to "Login". If it still asks for Username and password, you need to check your code signing. Go to the Build Setting and under code signing select the respected developer's certificate. It works for me.
On macOS Catalina, you have to:
Open Keychain Access.
Find your developer cert under the System category on the left.
Right or Double click the cert to open the Get Info window.
Expend the Trust dropdown above the cert details.
Open the drop down menu options for Code Signing.
Set the value to Always Trust.
It may be a good idea to quit and restart xCode after this if it was open, but when I changed mine I didn't bother and it still worked as expected.

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.
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
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:
Make sure there are no certificates in the System > Certificates tab on Keychain Access. Remove all duplicate certificates from there.
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.
Close Xcode!
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.
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.
Lastly regenerate your certs in XCode and rebooot
Reopen xcode
regenerate a new cert by going to project ->
General --> Signing
reselect your "Team Account"
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:
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.
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.

Resources