When I first installed Xcode 10.1 I didn't have an Apple Developer account. I probably used some self-signed certificate in order to build and run iOS apps. I don't think I ever got to the point of being able to install on a real device but I was able to run the simulator.
Since then I have created a Developer account and I am able to load that account into Xcode. I see it in Preferences.
However, I am having issues with certificates. The Team ID (10-characters, XYZ1234567) in my developer account is different from the the certificate in my KeyChain (ABC1234567). So naturally when I pull up Preferences, it has an iOS Developer certificate but it says it's not in my KeyChain. My hunch is it's because these team ids don't match. The ABC1234567 Team ID was generated before I got a developer account.
I've tried to delete all certs out of the KeyChain and start from fresh by submitting a CSR to my account, generating a cert, downloading it and then uploading the .cer into my KeyChain. To no avail, I see the old Team ID that doesn't match.
When I say Team ID, I mean the 10-digit code, not my email address.
UPDATE: When I generate a Distribution cert, it does reflect my developer Team ID. I have since learned that the Developer cert is supposedly random and wouldn't reflect my developer Team ID. Yet if this is truly random, why do I always get the same 10-character ID. I'm assuming it's based on my Mac's machine so that's why it never changes.
BTW, I am new to Xcode and apple development. I guess that's obvious.
This came into play when I tried to run my iOS app from Xcode on to a real device. This device is a locked phone with no internet connection. When I try to install, it gives me a certificate error.
Looking in my keychain(s) I realized that I had a royal mess. I had public/private keys not associated with valid certificates, etc. So I just deleted everything and started from scratch. Then I was able to create the CSR, upload it to my developer account, download it and then upload the new .cer into my login keychain. It needs to show up in MyCertificates. I then trusted it and I saw that it generated the public/private keys.
Now when I go into Xcode Preferences, I DO see that the iOS development cert is loaded correctly and no longer says "Not in KeyChain."
Lesson learned.