"A valid signing identity matching this profile..." and Xcode error - xcode

Our company is setting up another development station for the same app that will be sent away. I installed Xcode and tested the app in the simulator. I downloaded the Certificate and Provision that worked fine on my other computer. I selected the correct code signing identity and when I build it for a release to my iPad I get an error:
Code Sign error: The identity 'iPhone Developer: Person's Name (XXXXXXXX)' doesn't match any valid certificate/private key pair in the default keychain
In organizer, I click on Provision Profiles and the provision profile I downloaded. Underneath I get the warning:
A valid signing identity matching this profile could not be found in your keychain
I've looked up many, many other people that had this problem, but all seem to resolve it by deleting the cert and provision, which I never want to do! i.e., what if I want to use the same provision and cert on two different machines, or many?

I also went through deleting, recreating, deleting, rinse-repeat - but the answer was simple.
I had the same problem and solved it very simply in XCode Organizer - I'm using Version 4. All I did was go to the top Library section and select Provisioning Profiles, and import the downloaded profiles that I had received in my Safari downloads named "name.mobileprovision".

I think you just have to export the valid certs from the working computer, explained in this doc.
http://developer.apple.com/library/ios/#qa/qa2008/qa1618.html

Related

Why am I getting the error "Command /usr/bin/codesign failed with exit code 1" in Xcode 6 on Yosemite?

I'm using Xcode 6.1, OS X Yosemite preview 8, and I'm getting the following error on code signing my app:
Command /usr/bin/codesign failed with exit code 1
Reading on Google, it seems to be linked to expired certificates/provisioning profiles. I deleted all of my certificates & profiles, created a new development certificate & profile, installed both, restarted my Mac, and I’m still getting the same error.
Can anyone shed some light on how to resolve this problem?
How about this: Try Xcode -> Preferences -> Accounts -> Choose your account, and then View Details -> Refresh (button on bottom left), Refresh again, restart XCode. Sounds like voodoo but it works for me and my team! (Posting it as answer, because it DOES work, at least sometimes and for some people. Possibly related to the weather ;) )
as of Xcode 6.3.2, here's what I did.
from main project view, click on build settings and in the search bar type in certificate, a code signing tab should pop up, I chose "dont sign code". and it worked
So I've managed to fix the issue for my particular case - in the build settings, instead of automatically detecting the certificate & provisioning profile to use, I manually set them - and it works.
In my case I was getting this error while trying to build a project I downloaded from Github for my own personal use. I just went to the build settings and told it not to sign the code.
Another gotcha I noticed is that codesign will fail if run from an ordinary ssh login session. It has to be run on a MacOSX desktop GUI shell window. This catches me every time, so I've added a line to the build script to print a message about running the script on the MacOSX GUI if codesign fails.
Delete previous provisional profile and add new provisional profile.restart the machine if still its giving an error like above. when your machine shut off then automatically your device asking for permission then select Confirm and run your code....its working.
There appears to be a bug in XCode (I'm using 7.1.1) with returning to "Signing: None" after having attempted to sign with an expired identity, resulting in this codesign error even after you've apparently removed the bad signing identity.
The project.pbxproj file retains TargetAttributes for the expired identity, and Debug and Release settings both continue to show the following instead of the original empty values:
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer";
This persists after cmd+alt+shift+K and closing XCode. I fixed it with a git reset (if I hadn't committed before attempting to sign, I'm not sure how I would have found this).
I had to delete all my developer certificates from Keychain Access first, then use the Preferences -> Accounts -> View Details -> Download All approach to successfully re-sign my code.

Code signing error with sample app / new Provisioning Profile not in 'Code Signing' list

There are Code Signing Error issues on this forum but I couldnt find answer specific to my situation.
I have two issues really.
First issue:
I'm getting a "A valid provisioning profile matching the application's Identifier 'com.yourcompany.thisSampleApp' could not be found" error.
I get this error running on the Device (iPhone 4S) for which I have a valid Provisioning Profile - com.mycompany.*.
Since this didnt work, I created a Provisioning Profile for Bundle Identifier com.mycompany.thisSampleApp.
Same error.
Second issue:
I also noticed another thing, my newly created Provisional Profile does not show up in the 'Code Signing' section...so I cant even pick it.
But...I can see both the Provisional profiles listed in the Organizer window.
I downloaded Apple's Reachability sample Apple. Same error.
Any ideas anyone? Thanks!
PS: I'm running Xcode 4.6
when that happens to me, (and it happens a lot), I usually restart XCode, sometimes even the computer. If you are sure you have the correct provisioning profile, and the correct certificates in your keychain, and you have the correct bundle identifier.
Also, go to the target -> Build Settings -> Code Signing, and re-select the correct one.
Hope that helps.

Provisioning for Distribution

I can run the app fine through the development profile but I can't run it through the distribution profile. I have everything setup correctly as far as I can tell. The error that I get from xcode on compile is:
Code Sign error: No unexpired provisioning profiles found that contain any of the keychain's signing certificates
and in TARGETS > Release > Any iOS SDK I look under what should the correct line item and I see the following:
Profile doesn't match any valid certificate/private key pair in your keychains
So it sounds like my current cert doesn't allow me to run my app as distribution? I went into the member center and dirtied all related profiles and restarted xcode 4.6 after updating my profiles. Doesn't seem to work.
I also checked my Info.plist and the bundle name is correct there. It's also correct in TARGETS > Summary > Bundle Identifier.
A private key is missing
I noticed this morning that there is no private key underneath the iPhone Distribution cert in my Keychain Access and I suspect that's an issue? I'm an admin in the developer portal so I'm not sure why this wouldn't be working..
If you weren't on the distribution certificate when it was signed then you need to have someone who IS on the certificate to export their cert + private key for you. If in doubt, it's probably the dev portal agent who you need this from. The details are found in the answer for the question below:
Profile doesn't match any valid certificate/private-key pair in the default keychain

Error : The associated package identity has expired

I'm trying to validate an archive, before submitting it to the app store, but I keep getting the following error :
"MY NAME" is a valid identity. However, the associated package
identity "MY NAME" has expired.
There is an option to "Refresh Code Signing Identity", but nothing seems to happen.
What could be going wrong? Any ideas?
Hint : It's not my first time uploading an archive to the app store; I've already done that like 100 times. The thing is I'm using a different development machine and think that probably this is the one to blame. But I'm still confused...
I had the same issue. Deleting the expired developer certificates via "Keychain Access" did the trick for me.
From Keychain Access, View, Show Expired Certificates and delete all of them.
MAS: Code Signing Identity Private Key
Francesco Germinara
I had this exact error message, and it turns out that I needed to download and install both the Mac App certificate as well as the Mac Installer certificate, but I had only downloaded the Mac App one.

Application always asks for permission to access keychain

I have an application that stores username and password in the keychain. Everything was working fine when working on Xcode 3, I recently moved to Xcode 4 and now when I run the application, I get a prompt:
Application wants to use your confidential information stored in keychain" in your keychain.
After hitting always allow I see the application added to access control list of the keychain item, but I get every time I run the app.
Also after hitting Always allow again, I see that the access control has two instances of the same app. Seems like OS thinks this is a new application.
Any ideas appreciated.
I believe the problem is that your signature's designated requirement causes it to not accept itself as "the same app" as itself (for Keychain purposes).
One common cause for this—and I think it's yours—is using a Developer ID Application cert, with no designated requirement, and without the intermediate cert installed.
A standard Developer ID requirement looks like this:
designated => anchor apple generic and
identifier \"com.example.appName\" and
((cert leaf[field.1.2.840.113635.100.6.1.9] exists) or
(certificate 1[field.1.2.840.113635.100.6.2.6] exists and
certificate leaf[field.1.2.840.113635.100.6.1.13] exists and
certificate leaf[subject.OU] = \"1AZBYCXDW9V\" ))
If you want to construct this yourself, you have to replace the identifier with your bundle identifier and the subject.OU with the value from your cert. (If you double-click it in Keychain Access, it should be listed as the Organizational Unit.) Then you can add to "Other Code Signing Flags":
--requirements "=designated ..." (the whole mess from above)
However, a much better way to do this is to use Xcode 4.3.2 or later. If it recognizes that you're using a Developer ID Application cert, and can see the intermediate cert in the keychain, it will generate this by default.
Also, if you use the Archive Organizer in Xcode to "Export Developer ID-signed Application", instead of just using the build from your target directory, it will make sure to sign your app and any other enclosed signables, and it will test that everything is setup properly. (The failures are pretty cryptic—e.g., your "Choose a Developer ID to sign with" step may just have no choices, with a message in the syslog that has no useful information—but at least the fact that it failed or succeeded narrows down where your problem is.)
Either way, you need to download and install (on your build machine) the intermediate cert, called "Developer ID Certification Authority", from the "Developer ID Intermediate Certificate" link at the Developer Certificate Utility site.
One last thing: Even if this solves your problem running on your build machine, you really want to test on the oldest OS version you support. For example, the requirements compiled by Lion's codesign sometimes can't be parsed on Leopard, or sometimes even on Snow Leopard. If that happens… see Gatekeeper vs. Leopard: an ongoing tale.

Resources