ios 代码签名错误:应用程序代码签名验证失败

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

Code signing Error: Application failed codesign verification

iosxcodeosx-lion

提问by Mason Socha

I am very new to iOS development, I have an app all set and ready to be distributed, but I seem to get this error every single time I run the application on my DEVICE only, the iOS simulator works just fine. Heres the full error:

我对 iOS 开发非常陌生,我已经设置了一个应用程序并准备分发,但是每次我只在我的设备上运行应用程序时,我似乎都会收到这个错误,iOS 模拟器工作得很好。这是完整的错误:

Application failed codesign verification. The signature was invalid, contains disallowed entitlements, or it was not signed with an iPhone Distribution Certificate. (-19011)

应用程序未通过协同设计验证。签名无效、包含不允许的权利或未使用 iPhone 分发证书签名。(-19011)

Here's the entire log:

这是整个日志:

Validate "/Users/masonsocha/Library/Developer/Xcode/DerivedData/Multibrowser-brgeiknbjgrywwehhohafjwxjqnk/Build/Products/App Store-iphoneos/Multibrowser.app"
    cd /Users/masonsocha/Desktop/Apps/MultiBrowser
    setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    setenv PRODUCT_TYPE com.apple.product-type.application
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/Validation "/Users/masonsocha/Library/Developer/Xcode/DerivedData/Multibrowser-brgeiknbjgrywwehhohafjwxjqnk/Build/Products/App Store-iphoneos/Multibrowser.app"

warning: Application failed codesign verification.  The signature was invalid, contains disallowed entitlements, or it was not signed with an iPhone Distribution Certificate. (-19011)
Executable=/Users/masonsocha/Library/Developer/Xcode/DerivedData/Multibrowser-brgeiknbjgrywwehhohafjwxjqnk/Build/Products/App Store-iphoneos/Multibrowser.app/Multibrowser
codesign_wrapper-0.7.10: using Apple CA for profile evaluation
AssertMacros: trust_result == kSecTrustResultUnspecified,  file: codesign_wrapper.c, line: 594
AssertMacros: profile,  file: codesign_wrapper.c, line: 918
codesign_wrapper-0.7.10: Failed to load provision profile from: /Users/masonsocha/Library/Developer/Xcode/DerivedData/Multibrowser-brgeiknbjgrywwehhohafjwxjqnk/Build/Products/App Store-iphoneos/Multibrowser.app/embedded.mobileprovision
 - (null)

I have already tried shortening the length of the project name, that did not help, I am currently using OSX Lion, on Xcode 4.3.2. I have spent all night pulling my hair out, please help!

我已经尝试缩短项目名称的长度,但没有帮助,我目前在 Xcode 4.3.2 上使用 OSX Lion。我整晚都在拔头发,请帮忙!

采纳答案by Santthosh

I had the exact same issue..

我有完全相同的问题..

Go to Keychain Access

转到钥匙串访问

  1. Verify that you have your Public and Private keys set up correctly. This is a good reference https://developer.apple.com/legacy/library/technotes/tn2250/_index.html

  2. I had previously adjusted my Keychain Certificate Preferences to make Outlook work but that pretty much screwed up XCode code signing..

  1. 确认您的公钥和私钥设置正确。这是一个很好的参考https://developer.apple.com/legacy/library/technotes/tn2250/_index.html

  2. 我之前已经调整了我的钥匙串证书首选项以使 Outlook 工作,但这几乎搞砸了 XCode 代码签名..

After I set these to the "best attempt" setting (see screenshot) validation worked fine

在我将这些设置为“最佳尝试”设置后(见截图)验证工作正常

enter image description here

在此处输入图片说明

回答by muhamadto

May be xcode selects one of the development profile to sign the code with it.

可能是 xcode 选择了其中一个开发配置文件来对代码进行签名。

Make sure it uses the distribution profile

确保它使用分发配置文件

press the project, in the Build Settings -> Code Signing section expand Code Signing Identity -> Release - > make sure that Any iOS SDK is referring to distribution profile.

按项目,在 Build Settings -> Code Signing 部分展开 Code Signing Identity -> Release -> 确保 Any iOS SDK 指的是分发配置文件。

回答by Veeru

You could solve it is not leaving the profile selection to xcode. Manually select the correct releaseprofile in the project settings and it will go through.

您可以解决它不是将配置文件选择留给 xcode。在项目设置中手动选择正确的发布配置文件,它将通过。

回答by D Robey

I had same issue even after checking all signing stuff. I had the old "Can be debugged" setting in my entitlements file. Switching it to get-task-allowed fixed the problem. Apple has instructions on how to debug signing issues.

即使在检查了所有签名内容后,我也遇到了同样的问题。我的权利文件中有旧的“可以调试”设置。将其切换为 get-task-allowed 解决了该问题。Apple 有关于如何调试签名问题的说明

回答by D Robey

I had this problem but found that none of the above issues solved it. Eventually I found the solution by working through Apple's Technical Note (https://developer.apple.com/legacy/library/technotes/tn2250/_index.html) on the subject.

我遇到了这个问题,但发现上述问题都没有解决它。最终,我通过 Apple 的技术说明 ( https://developer.apple.com/legacy/library/technotes/tn2250/_index.html)找到了解决方案。

The specific problem in my case was an asset that was either missing or was hidden (I didn't find out which), but that wasn't flagged as a problem file anywhere else in the build process. I've outlined the steps I took to discover this below.

在我的案例中,具体问题是资产丢失或隐藏(我没有找到哪个),但在构建过程中的任何其他地方都没有标记为问题文件。我已经概述了我在下面发现这一点所采取的步骤。

  1. Archive the build, save for adhoc deployment.
  2. Navigate to the ipa in finder, rename to .zip.
  3. Double-click to unarchive, open the 'Payload' folder
  4. Open a Terminal, and enter the following:

    codesign --verify -vvvv -R='anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.1] exists and (certificate leaf[field.1.2.840.113635.100.6.1.2] exists or certificate leaf[field.1.2.840.113635.100.6.1.4] exists)' /Path/to/your/app.app

  5. Instead of entering /Path/to/your/app.app, drag and drop the *.app file from the Payload folder into the terminal, ensure there's a space between the end of the command and the filename, and hit return.

  1. 存档构建,保存用于临时部署。
  2. 导航到 finder 中的 ipa,重命名为 .zip。
  3. 双击解压,打开“Payload”文件夹
  4. 打开终端,输入以下内容:

    codesign --verify -vvvv -R='anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.1] 存在并且(证书叶[field.1.2.840.113635.100.6.1.2]存在或证书叶[field. 1.2.840.113635.100.6.1.4] 存在)' /Path/to/your/app.app

  5. 不要输入 /Path/to/your/app.app,而是将 *.app 文件从 Payload 文件夹拖放到终端中,确保命令末尾和文件名之间有一个空格,然后按回车。

I got an error in the output saying 'a sealed resource is missing or invalid', with the name of the file causing the problem (it began with a dot, which may have been the problem). When I searched for the filename in the XCode project browser I found the file, but when I looked in the Finder, it wasn't on disk.

我在输出中收到一条错误消息,指出“密封资源丢失或无效”,文件名是导致问题的原因(它以点开头,这可能是问题所在)。当我在 XCode 项目浏览器中搜索文件名时,我找到了该文件,但是当我查看 Finder 时,它不在磁盘上。

The fix was simply to remove the file from the XCode project browser, and the error went away. I would definitely say to anyone getting a similar problem - work through Apple's tech notes. They're a bit badly worded but the solution is likely to be in there somewhere.

修复只是从 XCode 项目浏览器中删除文件,错误就消失了。我肯定会对遇到类似问题的任何人说 - 通过 Apple 的技术说明工作。他们的措辞有点糟糕,但解决方案很可能就在某个地方。

回答by Mikael

I had the same problem and solved it by:

我遇到了同样的问题并通过以下方式解决了它:

  • 根据“将配置文件分配给构建配置”一节,“自动配置文件选择器”值从“iPhone 开发人员”更改为“iPhone 分发” 。
  • 下载分发供应配置文件并双击它以添加它。