ios Xcode 因“代码签名”错误而失败

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

Xcode fails with "Code Signing" Error

iphoneiosxcodecode-signingxcrun

提问by Richard Stelling

Alternate Titles

替代标题

(to aid search)

(帮助搜索)

  • Xcode 'CodeSign error: code signing is required'
  • Xcode: iPhone app codesign error
  • /usr/bin/codesign failed with exit code 1
  • Jenkins fails with Code Sign error
  • Command-line build fails with "provisioning profiles not found"
  • Archiving Xcode project fails with provisioning error
  • Missing signing certificates in Xcode
  • Xcode 'CodeSign 错误:需要代码签名'
  • Xcode:iPhone 应用程序协同设计错误
  • /usr/bin/codedesign 失败,退出代码为 1
  • Jenkins 因代码签名错误而失败
  • 命令行构建失败并显示“未找到配置文件”
  • 归档 Xcode 项目失败并出现配置错误
  • Xcode 中缺少签名证书

Symptoms

症状

The issue manifests it's self in one of several ways:

该问题以以下几种方式之一表现出来:

  • Running your app on a device results in an error referencing "code signing" or "expired signing certificates"
  • Building from the command line (or using a continuos integration system, such as Jenkins) fails with a error similar to this:

    Check dependencies
    Code Sign error: No unexpired provisioning profiles found that contain any of the keychain's signing certificates
    
  • Archiving an app fails with "code signing" or "expired signing certificates" where a run or build work correctly.

  • 在设备上运行您的应用程序会导致引用“代码签名”或“过期签名证书”的错误
  • 从命令行(或使用持续集成系统,例如Jenkins)构建失败,并显示类似于以下内容的错误:

    Check dependencies
    Code Sign error: No unexpired provisioning profiles found that contain any of the keychain's signing certificates
    
  • 归档应用程序失败并显示“代码签名”或“签名证书过期”,其中运行或构建正常工作。

Often the project may have several configurations and sometimes only a subset will fail. Deleting and regenerating provisioning profiles has no effect.

通常项目可能有多个配置,有时只有一个子集会失败。删除和重新生成配置文件无效。

回答by Richard Stelling

CODE_SIGN_IDENTITY verification script.

CODE_SIGN_IDENTITY 验证脚本。

Often in set ups that use version control the project.pbxprojcan be merged in such a way that two CODE_SIGN_IDENTITYlines can be inserted. This seems to cause Xcode problems under certain situations (like command-line builds or archiving).

通常在使用版本控制的设置中,可以以插入project.pbxprojCODE_SIGN_IDENTITY行的方式合并。在某些情况下(例如命令行构建或存档),这似乎会导致 Xcode 问题。

A tell-tail sign is lines similar to this in the project.pbxprojfile (right-click on the project and select "Show Package Contents…")

一个告示符号是project.pbxproj文件中与此类似的行(右键单击项目并选择“显示包内容...”)

"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_IDENTITY = "iPhone Distribution";

Deleting one of these lines will let you select the correct value in Build Settings and the project should once again build correctly.

删除这些行之一将使您在构建设置中选择正确的值,项目应该再次正确构建。

I have created simple script to help diagnose this issue it can be found here: https://github.com/rjstelling/Xcode-Project-Validate

我创建了简单的脚本来帮助诊断这个问题,它可以在这里找到:https: //github.com/rjstelling/Xcode-Project-Validate

回答by CodingYourLife

I got this code sign error with an Open Source Github project which I only wanted on my own device (not in store or anything) and I don't have a paid membership account.

我在一个开源 Github 项目中遇到了这个代码签名错误,我只想要在我自己的设备上(不在商店或任何地方),而且我没有付费会员帐户。

In that case it's meanwhile (since XCode 7) possible to configure and allow your app as unsigned but trusted.

在这种情况下,同时(自 XCode 7 起)可以将您的应用程序配置为未签名但受信任的应用程序。

It's all explained here: https://stackoverflow.com/a/4952845/828184

这一切都在这里解释:https: //stackoverflow.com/a/4952845/828184

回答by Abhijit

I had a similar problem which I could solve after a lot of wasted hours. So writing my solution here in case it helps someone.

我有一个类似的问题,我可以在浪费了很多时间后解决它。所以在这里写下我的解决方案,以防它对某人有所帮助。

My iOS app, which I have been developing and deploying/updating regularly for past 5 years, recently ran into a similar issue where final "Distribute App" via XCode Organizer started showing an error "Code Signing for MyAppName.app failed - see distribution logs for more information". The distribution logs have no information whatsoever.

我的 iOS 应用程序,我在过去 5 年里一直在定期开发和部署/更新,最近遇到了类似的问题,通过 XCode Organizer 的最终“分发应用程序”开始显示错误“MyAppName.app 的代码签名失败 - 请参阅分发日志想要查询更多的信息”。分发日志没有任何信息。

After a lot of trial-and-error, I found that the certificate used for code signing had somehow gone corrupt. I deletedthe certificate and it fixed the problem. Hope this helps someone.

经过大量的反复试验,我发现用于代码签名的证书不知何故已损坏。我删除了证书并解决了问题。希望这可以帮助某人。