由于钥匙串中没有钥匙,Xcode 代码签名错误

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

Xcode Code Sign error because of no Keys in Keychain

iosxcodekeykeychainsigning

提问by larssy1

You might think, not again such a question where are already thousands of topics about. However, I've not been capable of finding the answer I needed to fix this problem.

您可能会想,不再是这样一个问题,那里已经有数千个话题了。但是,我一直无法找到解决此问题所需的答案。

None of these topics go as deep as the Keychain.

这些主题都没有钥匙链深入。

When I'm trying to deploy my app to an iPhone, I'm receiving the following message:

当我尝试将我的应用程序部署到 iPhone 时,我收到以下消息:

Code Sign error: The identity 'iPhone Developer: [Name] ([ID])' doesn't match any valid, non-expired certificate/private key pair in your keychains.

Now, as said, I have been looking for multiple guides or fixes, however, none of them seemed to fix this issue.

现在,如上所述,我一直在寻找多个指南或修复程序,但是,它们似乎都没有解决这个问题。

Things I've tried:

我尝试过的事情:

  • Use Apple's walkthrough for app deployment for countless of times
  • Searched the internet for guides for app deployment
  • Changed the content of the 'pbxproj' file inside the 'xcodeproj' package.
  • Retrieve all available profiles from Apple's server using the Refresh button in Xcode 4.6 (allows you to obtain automatically)
  • 无数次使用苹果的app部署攻略
  • 在互联网上搜索应用程序部署指南
  • 更改了“xcodeproj”包中“pbxproj”文件的内容。
  • 使用 Xcode 4.6 中的 Refresh 按钮从 Apple 的服务器检索所有可用的配置文件(允许您自动获取)

After trying all of these ways, I've still not been able to solve the issue. One problem I've seen is that at first hand, the certificate in the Keychain was showing an invalid status, which is now solved.

在尝试了所有这些方法后,我仍然无法解决问题。我看到的一个问题是,一开始,钥匙串中的证书显示无效状态,现在已解决。

However, if I'm right, there are supposed to be two keys attached to the certificate. A public and private key, and these are not showing.

但是,如果我是对的,应该有两个密钥附加到证书上。公钥和私钥,这些都没有显示。

Neither are there any keys showing in the Keys tab in the Keychain Access.

Keychain Access 的 Keys 选项卡中也没有显示任何密钥。



Solution

解决方案

(Thanks to nsgulliver)

(感谢 nsgulliver)

  1. Do everything what the post (marked as Solution) of nsgulliver says.
  2. If you already have an active Certificate, click the Revoke button, this won't cause any trouble, you'll simply have to re-create the keys of which then will be generated a new certificate.
  3. Make sure you have the WWDR of Apple installed to mark the certificate authority as valid.
  4. Follow the default Provisioning Assistant guidelines.
  1. 做 nsgulliver 的帖子(标记为解决方案)所说的一切。
  2. 如果您已经有一个活动证书,请单击“撤销”按钮,这不会造成任何问题,您只需重新创建密钥,然后将生成一个新证书。
  3. 确保您安装了 Apple 的 WWDR 以将证书颁发机构标记为有效。
  4. 遵循默认的 Provisioning Assistant 指南。

采纳答案by nsgulliver

Provisioning profiles installed on the devices or signed with for the target might not be valid, try to go to Organizer->Provisioning profileand see if the profiles have the valid status? if not try to delete & refresh them, if they appear valid after refreshing then it might solve your problem if not then you should remove all the entries from keychainand delete profiles on your provisioning portal and try to create from scratch, if you still face the problem then take help from step by step guide tutorial

安装在设备上或为目标签名的配置文件可能无效,请尝试Organizer->Provisioning profile查看配置文件是否具有有效状态?如果不尝试删除并刷新它们,如果它们在刷新后看起来有效,那么它可能会解决您的问题,如果不是,那么您应该从keychain配置门户中删除所有条目并删除配置文件,并尝试从头开始创建,如果您仍然面临问题然后从分步指南教程中寻求帮助

回答by Jim

You cannot re-create matching keys, that would defeat the whole purpose of them. You need to find the old keys or start the signing procedure from scratch.

您不能重新创建匹配的密钥,这会破坏它们的全部目的。您需要找到旧密钥或从头开始签名过程。

Are you using the same machine that you generated the keys on? If not, go to the other machine, export the developer profile, then import it on the new machine.

您使用的是生成密钥的同一台机器吗?如果没有,请转到另一台机器,导出开发人员配置文件,然后在新机器上导入。

Can you restore the keys from backups? If not, stop everything you are doing and configure your computer for backups before you do anything else.

你能从备份中恢复密钥吗?如果没有,请停止您正在执行的所有操作并在您执行任何其他操作之前配置您的计算机进行备份。

If you are really stuck, you will have to follow the signing procedure right from the very beginning, where you request a certificate from a certificate authority. This will generate new keys, and you will have to create matching provisioning profiles, then set your application to be signed with these. Dlete the old provisioning profiles, they will be useless without the old keys.

如果您真的遇到困难,则必须从一开始就遵循签名程序,即从证书颁发机构请求证书。这将生成新密钥,您必须创建匹配的配置文件,然后将您的应用程序设置为使用这些密钥进行签名。删除旧的配置文件,如果没有旧密钥,它们将毫无用处。

回答by Caleb

Required reading when you're having code signing problems:

遇到代码签名问题时的必读内容:

Technical Note TN2250: iOS Code Signing Troubleshooting

技术说明 TN2250:iOS 代码签名故障排除

Nothing will help you more than really understanding what's in your certificates and what isn't, where the necessary pieces are kept, and how they're used. This isn't the last time that you'll have code signing issues, and this tech note provides a long checklist that should help you make sure that everything is in the right place to help you develop your app and ultimately sign and submit it to the app store.

没有什么比真正了解证书中的内容和不包含的内容、必要部分的保存位置以及它们的使用方式更能帮助您了。这不是您最后一次遇到代码签名问题,本技术说明提供了一个很长的清单,可以帮助您确保一切都在正确的位置,以帮助您开发应用程序并最终签名并将其提交给应用商店。

回答by Alona Moiseyenko

You need to lock keychain. Please see screenshot:

您需要锁定钥匙串。请看截图:

enter image description here

在此处输入图片说明

回答by Manuel Schmitzberger

After removing all old provisioning profiles (~/Library/MobileDevice/Provisioning Profiles/) and updating xCode, the certificates can be found again.

删除所有旧的配置文件 ( ~/Library/MobileDevice/Provisioning Profiles/) 并更新 xCode 后,可以再次找到证书。

回答by jamssn

When I've had this problem in the past I've just deleted everything on my local machine and started again. So:

当我过去遇到这个问题时,我刚刚删除了本地机器上的所有内容并重新开始。所以:

  1. Delete the keys associated with your developer account in Keychain access.
  2. In XCode open the 'Organizer' (window->organizer)
  3. In Devices (top menu) and Provisioning Profiles (left menu), select all of the profiles and delete them.
  4. Now hit refresh. It will ask you to sign in and whether you want to generate new keys etc, select yes and wait.
  1. 在 Keychain 访问中删除与您的开发者帐户关联的密钥。
  2. 在 XCode 中打开“组织者”(窗口->组织者)
  3. 在设备(顶部菜单)和供应配置文件(左侧菜单)中,选择所有配置文件并将其删除。
  4. 现在点击刷新。它会要求您登录以及是否要生成新密钥等,选择是并等待。

I find that this is the quickest way to fix any provisioning / key problems, as you can spend hours finding that you've missed something small.

我发现这是解决任何配置/关键问题的最快方法,因为您可能会花费数小时发现自己错过了一些小问题。