由于证书问题,无法在设备上运行 Xcode 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46881907/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't run Xcode project on device due to certificate issues
提问by Michael W
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:
我正在尝试在 iPhone 6 Plus 上运行 Xcode 9.0.1 项目,但出现以下三个错误:
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'
代码签名错误:您输入的用户名或密码不正确。
代码签名错误:未找到签名证书“iOS 开发”:未找到与团队 ID“KP3X78QM3M”匹配的带有私钥的“iOS 开发”签名证书。
代码签名错误: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.
我怀疑这是由于 Xcode 无法读取我计算机上的开发人员证书造成的。这就是 Signing 下的 General 选项卡的样子。单击“再试一次”将生成一个新证书,但所有错误仍然存在。
I checked the Keychain Access application and it has an iPhone developer certificate, although I'm not sure if anything else is missing.
我检查了 Keychain Access 应用程序,它有一个 iPhone 开发人员证书,但我不确定是否还缺少其他任何东西。
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.
我查过类似的问题并开始阅读 Apple 的 Xcode 故障排除指南,但我仍然感到困惑,不想意外修改任何重要的内容。
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.
我迫切需要解决这个问题;如果有 Apple 支持电子邮件或我可以就此事亲自联系的人,那就太棒了。
Thanks in advance!
提前致谢!
回答by Michael W
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.
长话短说,当这两个错误仍然存在于“常规”选项卡的“签名”部分时,我退出了 Xcode。此时,单击首选项 -> 帐户 -> 管理证书仍然会给出“缺少私钥”这样的错误消息。
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!
退出 Xcode 后,我重新启动计算机并再次打开 Xcode。在“常规”选项卡的“签名”部分下,它提示我使用我的 Apple ID 登录。登录后,这两个错误消失了。我在 Mac 上打开了“钥匙串访问”应用程序,单击“我的证书”选项卡,注意到已经生成了一个包含新私钥的下拉箭头的新证书!
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.
要设置新密钥以使其正常工作,请将您的设备(在我的情况下为 iPhone 6 plus)连接到您的 Mac 并在设备上运行您的 Xcode 项目。应该会弹出一个标题为“代码设计需要钥匙串中的访问密钥“访问”。”的窗口,需要您的计算机的密码。
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"!!!
非常重要:输入您的计算机登录密码(不是您的 Apple ID 密码),然后单击“始终允许”!我很困惑,第一次不小心点击了“拒绝”,这首先让我陷入了困境。点击“始终允许”!!!
After this point, Xcode should be able to run your app on a device.
在此之后,Xcode 应该能够在设备上运行您的应用程序。
Good luck!
祝你好运!