Ios – Distribution certificate / private key not installed

certificateioskeychainxcode

Using Xcode 9.1, after building an iOS app, I want to archive it and upload it to the appStore for beta-testing.
But I get the following issue after clicking the button Upload to the App Store... and choosing Automatically manage signing:

"My Name" has one iOS Distribution certificate but its private key is
not installed. Contact the creator of this certificate to get a copy of the private key.

I do not know why this "private key is not installed", but the Distribution certificate may have been created on a different computer or something. In any case:

What is the simplest way to retrieve the missing private key and install it? In order to make things work.

Best Answer

Up to date (January 2021) (Xcode 10 - 12)

  1. Go to Xcode - Preferences - Accounts - Manage Certificates
  2. Click on the + at the bottom left, then Apple Distribution
  3. Wait a little, then click Done

That's all. You may want to revoke the old certificate on developer.apple.com too.

Old answer

Step 1: Xcode -> Product -> Archives -> Click manage certificate

Click manage certificate

Step 2: Add iOS distribution

Add iOS distribution