dapug
dapug

Reputation: 1941

How do I fix "Missing Private Key" for xcode apple provisioning?

On a new mac, I installed xcode and needed to set up provisioning for a hello-world project to deploy to my iPad.

NOTE: I am using the new FREE provisioning (do not have a paid Apple account)

  1. I went to Preferences/Account signed in to my Apple account
  2. In the project, General tab, Team is set to my (free) Apple Dev account. (all seemed well, it recognized this as valid)
  3. I tried to deploy to the iPad and I got a build error "codesign failed with exit code 1"
  4. Supposedly this is to do with certificates. I went to Keychain Access and found "iPhone Developer: [email protected] (...)" in there, which was added when I signed in via my Apple Account.
  5. I DELETED this key (thinking I would simply re-add my Apple Account and thus this key)
  6. I then removed and re-added my Apple account from xcode preferences
  7. I can sign-in, I can see it adds keys, and Keychain Access Get Info on the keys indicates no issues (valid, etc)
  8. In xcode Preferences, when I click Manage Certificates, it shows "David's MacBook Pro (2)" and a bunch of "Untitled" keys ALL of which have a status of "Missing Private Key".
  9. xcode/General/Status section says "The username or passphrase you entered is not correct" even though my "Team" is signed in and valid
  10. Clicking "Try Again" shows "Waiting to repair", followed by "revoking...", followed by "Generating certificates" - which sounds promising, like it's doing exactly what I need, but then fails, private keys still missing, and back to step 9 here in a loop of hell.

ok? How do I get this resolved without flattening my OS back to factory and starting completely over?

Note: there are resolutions on SO that talk about Revoking the keys and generating new private keys from the Dev Console, like this one: How can I add private key to the distribution certificate?

HOWEVER, on a "free" account I have NO access to the Certificates section! I can't manage anything from the Dev portal online. I do, however, see xcode specifically set up to handle certs (see step 9-10 above) but it is not working. I really don't know where to go from here. I'm new to all things Mac and iOS and xcode. Frustrated. Thanks Apple, so much for a simple on-boarding experience on a simple hello-world app.

Upvotes: 21

Views: 26491

Answers (2)

BruceHill
BruceHill

Reputation: 7164

I had this error and it occurred because I had moved to a new Macbook. Although there was a provisioning profile on our Apple account and it was not expired, the private key was on the old Macbook. So downloading and installing the profile did not help, as it was the private key that was missing. I revoked the provisioning profile and created a new one. I had the same issue for the distribution certificate.

If you are concerned whether revoking and creating new certificates/profiles will affect existing deployed applications, take a look at this question and the answers. The bottom line is, for applications on the app store it will have no affect, but for Enterprise Distributions, deployed applications will stop working if you revoke the provisioning profile. So if the application is on an Enterprise Account, then it is best to try find the private key in the keychain of the Macbook where it was created.

Upvotes: 0

resurrecteds
resurrecteds

Reputation: 5966

After two bounties for this question which gave no results, I managed to find a solution to this problem. Apparently, it was some keychain related problem.
To fix it:

  1. Open Keychain Access on your Mac.
  2. Right click on the "login" keychain in the left side of the window.
  3. Press Lock keychain "login".
  4. Then do the same to Unlock it.
  5. Go back to Xcode and try to set your app to run with your personal account.

Solution was found using the first comment here: https://github.com/desktop/desktop/issues/3625

Upvotes: 11

Related Questions