Unable to distribute ad hoc my iOS app in xCode

Hello,
I'm becoming crazy after struggling with this problem for many days. I'm unable to distribute ad-hoc my app because I receive this error:

"*** has one apple distribution certificate but its private key are not installed contact the creator of the certificate to get a copy of the private key"

xcode version: 11.3.1


This is the steps I did in xCode:
1- Linked xCode with my apple-id through the login section

2- in the signing menu section I checked "automatically manage signing" and provisioning profile is setup to "xcode managed". After that It created corretcly a new apple development certificate. In my keyChain the new certificate appeared with its private key

3- I built the app and the process ended correctly

4- In the organizer window the new distribution appeared and clicked "Distribute App", then selected "Ad Hoc" distribution

5- When It asked how would I have preferred to sign the distribution, I checked "Automatically signing". It said that a distribution certificate had to be created and I let it did. A new distribution certificate was successfully created.

6- In my keyChain the new distribution certificate appeared correctly with its private key.

7- I went in the web apple dev account manager and created a distribution profile with the new distribution certificate created at step 5 in xCode, I associated the list of permitted devices (previously created).

8- I came back to xCode to finish the signing process but I got the error saying that *** has one apple distribution certificate but its private key are not installed contact the creator of the certificate to get a copy of the private key.


In this last window of the error, if I click on "manage certificate" why it shows 2 certificate where one has missing privatekey? With step 5 I only created one distribution certificate and also in apple dev manager there is only one distr cert

Basic stuff like restarting mac, xcode had no success. I googled a lot the problem but the main fix, that is, ask the owner of the certificate for the private key, it dosen't work for me because I'm the owner of the distribution certificate that correctly appears in my keyChain with its private key.

Could be a problem related to the CSR? In generale do I need to inform xCode about what CSR to use? Or it does the csr stuff automatically and transparent to the user?

Could be a bug of this xCode version?

The following images contains details about the error




Accepted Reply

I'm in the same situation - nearly - I'm trying to get an app into TestFlight, not do an Ad-Doc distro. I get the same 'private key not installed' error.

I'm using XCode 10.3 - so maybe not a XCode bug, @Vinterlord.

I can see in KeyChain Access that my certificates definitely do have the private key installed (I can see it when I expand the certificate).

I've been through many forum answers that recommend clicking 'Manage certificates' and creating a new iOS Distro certificate (I get the error "You already have a current iOS Distribution certificate or a pending certificate request"), or downloading the certificates from the developer portal and reinstalling them on my machine. There are other suggestions but they seem to be out of date.

If I try manually signing the app, I eventually receive an 'App Store Connect Operation Error' because my app 'is not signed using an Apple submission certificate'

Replies

I'm in the same situation - nearly - I'm trying to get an app into TestFlight, not do an Ad-Doc distro. I get the same 'private key not installed' error.

I'm using XCode 10.3 - so maybe not a XCode bug, @Vinterlord.

I can see in KeyChain Access that my certificates definitely do have the private key installed (I can see it when I expand the certificate).

I've been through many forum answers that recommend clicking 'Manage certificates' and creating a new iOS Distro certificate (I get the error "You already have a current iOS Distribution certificate or a pending certificate request"), or downloading the certificates from the developer portal and reinstalling them on my machine. There are other suggestions but they seem to be out of date.

If I try manually signing the app, I eventually receive an 'App Store Connect Operation Error' because my app 'is not signed using an Apple submission certificate'
@Luke-f
yes it is frustrating, if I also try to sign it manually with the downloaded distribution profile, xCode says it cannot recognize the certificate inside it even if it can generate the distribution. But when I try lo launch the app manually signed in my iPhone, it crashes at the splash screen
I fixed it by resetting my macosx machine from scratch. Probably there was something corrupted in the keyChain, or more likely there was something missing in the keyChain and that could not be restored.

Resetting from scratch my os fixed it
im facing the same problem for 13 days now trying to figure the problem with no luck :/

@Vinterlord did you reset all files and settings, or there's a way to not erase the files ?
Same problem... @Vinterlord How you reset os? You mean full reinstall?
@all

yes I had to fully reset the machine and reinstall from scratch macosx catalina os. I have a dedicated machine for doing the building of ios mobile apps so I didn't really care about backups.

As for my understading, the old keyChain was pheraps missing some public keys of certain Apple CAs, but the distribution private key was correctly present because it was generated by Xcode.

I'm saying this because after the reset, I opened the keyChain and I noticed there were new CA certificates compared to the old bugged keyChain. Moreover, in the bugged keyChain the distribution certificate (with its privateKey inside) was reported as "non-trusted", this might suggest that the OS couldn't decrypt and trust it with any of the CA's public key already present in the keyChain.

I don't know if apple has changed some policy and/or updated their CAs because my machine was working well for its purpose and suddenly showed the problem when I generated a new distribution certificate in Xcode.

Hope this helps
Reinstallation Mojave OS did not save me. Same error continue to appear and prevent me from sending app to appstore.
@sarslander

mhmm, by the way it is a really weired behavior this thing about private keys. I don't know if it might be of help, but I have updated from mojave to catalina when reinstalling the os in my machine. Catalina is the last version, maybe it has updated CAs and stuff in the keyChain.. but it is just my guessing.. I also have installed the current last stable version of Xcode


my friends also a developer, work on big sur os, i give him my apple developer account and tell him to start all over the app distribution process , everything works fine with him, then i told him to export the CAs work fine with him and even that for me the same problem, so now i was thinking to reset my with capitaen os
Ps : i have moraje
@Soukbench

check you keyChain and see if your distribution certificate's private key is marked as "non-trusted" this may suggest there is something wrong with CA's certificate. For me it was like that in the old buggy keyChain
UPDATE :
update from os from mojave to catalina without losing data didnt solve the problem for me
but when i reset the catalina os from scratch did solve it !
hope this is helpful
I upgraded OS to Catalina and try to using Xcode 11 but had same error. After upgrade to Xcode 12 problem finally solved.