Can't run Xcode project on device due to certi

2019-06-12 08:06发布

问题:

This is the first question I've ever posted.

I am trying to run an Xcode 9.0.1 project on an iPhone 6 Plus and these three errors come up:

  • Code Signing Error: The user name or passphrase you entered is not correct.

  • Code Signing Error: No signing certificate "iOS Development" found: No "iOS Development" signing certificate matching team ID "KP3X78QM3M" with a private key was found.

  • Code Signing Error: Code signing is required for product type 'Application' in SDK 'iOS 11.0'

I suspect this is caused by Xcode not being able to read the developer certificates on my computer. This is what the General tab looks like under Signing. Clicking "Try Again" will generate a new certificate but all of the errors still remain.

I checked the Keychain Access application and it has an iPhone developer certificate, although I'm not sure if anything else is missing.

I've looked up similar questions and started reading Apple's Xcode troubleshooting guide but I am still confused and don't want to accidentally modify anything important.

I desperately need to fix this issue; if there is an Apple support email or someone I can contact in person about this, that would be amazing.

Thanks in advance!

回答1:

I found a solution!

Even though this question only has a few views, I'll share it in case anyone else has the same problem in the future.

Long story short, I Quit Xcode while the two errors were still present in the Signing section of the General tab. At this point, clicking Preferences -> Accounts -> Manage Certificates still gave the "Missing Private Key" error messages like so.

After quitting Xcode I restarted the computer and opened Xcode again. Under the Signing section for the General tab, it prompted me to log in with my Apple ID. After logging in, the two errors were gone. I opened the "Keychain Access" application on the mac, clicked on the "My Certificates" tab and noticed that a new certificate had been generated WITH a drop down arrow that contained a new private key!

To set up the new key so it works, connect your device (in my case an iPhone 6 plus) to your mac and run your Xcode project on the device. A window titled 'codesign wants access key "access" in your keychain." should pop up, wanting the password for your computer.

VERY IMPORTANT: Type your computer login password (not your Apple ID password) and click ALWAYS ALLOW! I got confused and accidentally hit "Deny" the first time around which is what got me into this mess in the first place. Click "ALWAYS ALLOW"!!!

After this point, Xcode should be able to run your app on a device.

Good luck!