I'm making a .Net MAUI app that I want to publish to iOS.
I've done so successfully from my primary PC, after enrolling into Apple dev program and generating all required keys and certificates. However now I'm trying to develop from my laptop and I cannot get Hot Start to run:
There was an error while trying to automatically provision the project: 'Certificate: Apple Development: Created via API () already exists but cannot be found in the local Keychain. It may have been created on another development machine. Import the certificate and private key from that machine or revoke it and try again to automatically create a new one'
Now I can live with that for now. However I'm going to need my laptop tomorrow in order to publish the app to the App Store, because I don't have a Mac lying around at home.
The first time I got this error I was confused, because I was trying to authenticate with the exact same certificate I use on the other machine. Then I tried to create a second certificate pair on that machine and use that however it didn't work again. Exact same error to be precise, which is odd, because while I added the new certificate in Xamarin.AppleAcount settings, the error contained the certificate key from my original cetrtificate (the one that's working on the other machine).
I have not yet tried to revoke that one, but I'm reluctant to do so, because I don't want to risk breaking the setup that I have working only for it to fail again on my laptop.
Creating different certificates and profiles is a solution, you can also import the certificate into another Mac or Windows machine. This requires you export the p12 file from Keychain in your first Mac.
Detailed Steps: Open Keychain Access ->Login->Certificates>Expand the certificate so the associated private key is visible, right-click on the key and chose Export. (You will be prompted for a filename and a password) Transfer and save the file to another mac, then import the certificate: Open Keychain Access ->File->Import Items->select the certificate that exported (enter the password).
If you want to import this certificate into your Windows machine: Open VS->Tools->Options->Xamarin->Apple Accounts->select your team->View details->Import Certificate After that, you can download the provisioning profile and double-click the profile to install into your Mac (For Windows machine, you can open VS->Tools->Options->Xamarin->Apple Accounts->select your team->View details->Download all profiles) Then you can select the matching certificate and provisioning profile in Properties->iOS->Bundle Signing-> Manual Provisioning.
In addition, you can also refer to this case which has the same error message Xamarin Hot Restart: get "Certificate already exists but cannot be found in the local keychain" and fixed this error without creating different certificates and profiles.