如何修复 xcode 苹果配置的“缺少私钥”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48752781/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 10:33:21  来源:igfitidea点击:

How do I fix "Missing Private Key" for xcode apple provisioning?

xcodecode-signingkeychainios-provisioning

提问by dapug

On a new mac, I installed xcode and needed to set up provisioning for a hello-world project to deploy to my iPad.

在一台新 Mac 上,我安装了 xcode 并需要为一个 hello-world 项目设置配置以部署到我的 iPad。

NOTE: I am using the new FREE provisioning (do not have a paid Apple account)

注意:我正在使用新的免费配置(没有付费的 Apple 帐户)

  1. I went to Preferences/Accountsigned in to my Apple account
  2. In the project, Generaltab, Teamis set to my (free) Apple Dev account. (all seemed well, it recognized this as valid)
  3. I tried to deploy to the iPad and I got a build error "codesign failed with exit code 1"
  4. Supposedly this is to do with certificates. I went to Keychain Accessand found "iPhone Developer: [email protected] (...)" in there, which was added when I signed in via my Apple Account.
  5. I DELETED this key (thinking I would simply re-add my Apple Account and thus this key)
  6. I then removed and re-added my Apple account from xcode preferences
  7. I can sign-in, I can see it adds keys, and Keychain Access Get Infoon the keys indicates no issues (valid, etc)
  8. In xcode Preferences, when I click Manage Certificates, it shows "David's MacBook Pro (2)" and a bunch of "Untitled" keys ALL of which have a status of "Missing Private Key".
  9. xcode/General/Statussection says "The username or passphrase you entered is not correct" even though my "Team" is signed in and valid
  10. Clicking "Try Again" shows "Waiting to repair", followed by "revoking...", followed by "Generating certificates" - which sounds promising, like it's doing exactly what I need, but then fails, private keys still missing, and back to step 9 here in a loop of hell.
  1. 我进入了使用我的 Apple 帐户登录的首选项/帐户
  2. 在项目的General选项卡中,Team设置为我的(免费)Apple Dev 帐户。(一切似乎都很好,它认为这是有效的)
  3. 我尝试部署到 iPad,但出现构建错误“ codesign failed with exit code 1
  4. 据说这与证书有关。我去了Keychain Access并在那里找到了“ iPhone Developer: [email protected] (...)”,这是我通过 Apple 帐户登录时添加的。
  5. 我删除了这个密钥(我想我会简单地重新添加我的 Apple 帐户,从而重新添加这个密钥)
  6. 然后我从 xcode 首选项中删除并重新添加了我的 Apple 帐户
  7. 我可以登录,我可以看到它添加了钥匙,钥匙上的钥匙串访问获取信息表明没有问题(有效等)
  8. 在 xcode Preferences 中,当我单击Manage Certificates 时,它会显示“David's MacBook Pro (2)”和一堆“Untitled”键,所有这些键的状态都是“ Missing Private Key”。
  9. xcode/General/状态部分显示“您输入的用户名或密码不正确”即使我的“团队”已登录且有效
  10. 单击“再试一次”显示“等待修复”,然后是“撤销...”,然后是“生成证书”——这听起来很有希望,就像它在做我需要的事情,但后来失败了,私钥仍然丢失,并且在地狱循环中回到第 9 步。

ok? How do I get this resolved without flattening my OS back to factory and starting completely over?

好?如何在不将我的操作系统压平回工厂并完全重新开始的情况下解决这个问题?

Note: there are resolutions on SO that talk about Revoking the keys and generating new private keys from the Dev Console, like this one: How can I add private key to the distribution certificate?

注意:SO 上有一些关于从 Dev Console 撤销密钥和生成新私钥的解决方案,例如: 如何将私钥添加到分发证书?

HOWEVER, on a "free" account I have NO access to the Certificates section! I can't manage anything from the Dev portal online. I do, however, see xcode specifically set up to handle certs (see step 9-10 above) but it is not working. I really don't know where to go from here. I'm new to all things Mac and iOS and xcode. Frustrated. Thanks Apple, so much for a simple on-boarding experience on a simple hello-world app.

但是,在“免费”帐户上,我无法访问“证书”部分!我无法从 Dev 门户在线管理任何内容。但是,我确实看到 xcode 专门设置为处理证书(请参阅上面的步骤 9-10),但它不起作用。我真的不知道从这里去哪里。我是 Mac、iOS 和 xcode 的新手。沮丧的。感谢 Apple,让我们在简单的 hello-world 应用程序上获得简单的入门体验。

回答by resurrecteds

After two bounties for this question which gave no results, I managed to find a solution to this problem. Apparently, it was some keychain related problem.
To fix it:

在这个问题没有结果的两次悬赏之后,我设法找到了这个问题的解决方案。显然,这是一些与钥匙串相关的问题。
要解决这个问题:

  1. Open Keychain Access on your Mac.
  2. Right click on the "login" keychain in the left side of the window.
  3. Press Lock keychain "login".
  4. Then do the same to Unlock it.
  5. Go back to Xcode and try to set your app to run with your personal account.
  1. 在 Mac 上打开钥匙串访问。
  2. 右键单击窗口左侧的“登录”钥匙串。
  3. 按锁定钥匙串“登录”。
  4. 然后做同样的解锁。
  5. 返回 Xcode 并尝试将您的应用设置为使用您的个人帐户运行。

Solution was found using the first comment here: https://github.com/desktop/desktop/issues/3625

使用此处的第一条评论找到了解决方案:https: //github.com/desktop/desktop/issues/3625