简体   繁体   English

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

[英]Xcode Code Sign error because of no Keys in Keychain

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.更改了“xcodeproj”包中“pbxproj”文件的内容。
  • Retrieve all available profiles from Apple's server using the Refresh button in Xcode 4.6 (allows you to obtain automatically)使用 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.做 nsgulliver 的帖子(标记为解决方案)所说的一切。
  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.确保您安装了 Apple 的 WWDR 以将证书颁发机构标记为有效。
  4. Follow the default Provisioning Assistant guidelines.遵循默认的 Provisioning Assistant 指南。

Provisioning profiles installed on the devices or signed with for the target might not be valid, try to go to Organizer->Provisioning profile and see if the profiles have the valid status?安装在设备上或为目标签名的配置文件可能无效,请尝试转到Organizer->Provisioning profile并查看配置文件是否具有有效状态? 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 keychain and 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如果不尝试删除并刷新它们,如果它们在刷新后看起来有效,那么它可能会解决您的问题,如果不是,那么您应该从keychain删除所有条目并删除配置门户上的配置文件并尝试从头开始创建,如果您仍然面临问题然后从分步指南教程中寻求帮助

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.删除旧的配置文件,如果没有旧密钥,它们将毫无用处。

You need to lock keychain.您需要锁定钥匙串。 Please see screenshot:请看截图:

在此处输入图片说明

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.这不是您最后一次遇到代码签名问题,本技术说明提供了一个很长的清单,可以帮助您确保一切都在正确的位置,以帮助您开发应用程序并最终签名并将其提交给应用商店。

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.在 Keychain 访问中删除与您的开发者帐户关联的密钥。
  2. In XCode open the 'Organizer' (window->organizer)在 XCode 中打开“组织者”(窗口->组织者)
  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.它会要求您登录以及是否要生成新密钥等,选择是并等待。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM