ios Xcode 命令 /usr/bin/codesign 失败,退出代码为 1:errSecInternalComponent

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

Xcode Command /usr/bin/codesign failed with exit code 1 : errSecInternalComponent

iosxcodecertificateprovisioning-profile

提问by Alex Pelletier

I am trying to add new provisioning profile to my Xcode, to test an app on the device. Here are the steps I followed:

我正在尝试向我的 Xcode 添加新的配置文件,以测试设备上的应用程序。以下是我遵循的步骤:

  1. Deleted all certificates and provisioning profiles

  2. Create/Add IOS Dev Certificate

  3. Add My IOS Device Online

  4. Create IOS Provisioning Profile

  5. Add IOS Provisioning Profile

  6. Clean App

  7. Build Then Run App

  8. Set Codesigning nd Provisioning Profile In Build Settings

  9. Lots of Googling > to no successes

  1. 删除了所有证书和配置文件

  2. 创建/添加 IOS 开发证书

  3. 在线添加我的 IOS 设备

  4. 创建 IOS 配置文件

  5. 添加 IOS 配置文件

  6. 清洁应用

  7. 构建然后运行应用程序

  8. 在构建设置中设置编码和供应配置文件

  9. 大量的谷歌搜索 > 没有成功

Here is the error I get:

这是我得到的错误:

CSSM_SignData returned: 800108E6
/Users/alexpelletier/Library/Developer/Xcode/DerivedData/MyExpense-efnqzvoqwngzcmazaotyalepiice/Build/Products/Debug-iphoneos/MyExpense.app:     errSecInternalComponent
Command /usr/bin/codesign failed with exit code 1

回答by Mohit Manhas

Open Keychain Access, then in the Filemenu select Lock All Keychains.

打开钥匙串访问,然后在文件菜单中选择锁定所有钥匙串

Then go back to Xcode and clean and rebuild. It will prompt you for your password again to unlock the keychain.

然后返回 Xcode 并清理和重建。它会再次提示您输入密码以解锁钥匙串。

After this, assuming you have no other compile issues, it will succeed!

在此之后,假设您没有其他编译问题,它将成功!

回答by sigabrt

It seems like a bug in the code signing mechanism, restarting your mac should solve the problem

似乎是代码签名机制中的一个错误,重新启动您的 mac 应该可以解决问题

回答by cbracken

This occurs when the login keychain is locked. To unlock the login keychain, run:

当登录钥匙串被锁定时会发生这种情况。要解锁登录钥匙串,请运行:

security unlock-keychain login.keychain

If your keychain is password-protected, specify the password using the -poption.

如果您的钥匙串受密码保护,请使用该-p选项指定密码。

Then try the build or code-signing operation again. The error code in question is described in Apple's docsas an internal error, so it's entirely possible this occurs in other cases too.

然后再次尝试构建或代码签名操作。有问题的错误代码在Apple 的文档中描述为内部错误,因此在其他情况下也完全有可能发生这种情况。

回答by Equilibrium

Had the same issue on High Sierra/Xcode 9.4.1, all attempts to sign ended in errSecInternalComponent

High Sierra/上有同样的问题Xcode 9.4.1,所有登录尝试都以errSecInternalComponent

    • Go to Keychain Access
    • Go to the login keychain
    • Select the category "My Certificates"
    • Find the certificate you're signing with and expand it to see the key.
    • Double click the key
    • Go to the "Access control" tab.
    • Update key access control to "Allow all applications to access this item"
    • 转到钥匙串访问
    • 转到登录钥匙串
    • 选择类别“我的证书”
    • 找到您要签名的证书并展开它以查看密钥。
    • 双击键
    • 转到“访问控制”选项卡。
    • 将密钥访问控制更新为“允许所有应用程序访问此项目”

Alternatively:

或者:

run codesign command on mac terminal and "Always allow" /usr/bin/codesign access to key

在 mac 终端上运行 codesign 命令并“始终允许” /usr/bin/codesign 访问密钥

  1. If trying to sign from ssh/CI you also need to run

    security unlock-keychain login.keychain
    

    before trying to sign app bundle

  1. 如果尝试从 ssh/CI 签名,您还需要运行

    security unlock-keychain login.keychain
    

    在尝试签署应用程序包之前

回答by ifeegoo

I have met the same problem, I restart my macOS,and it works.

我遇到了同样的问题,我重新启动了我的 macOS,它可以工作。

In China,we have a saying between developers:

在china,我们在开发者之间有一句谚语:

Little problems,just restart.Big problems,should reinstall.

小问题,重新启动。大问题,应该重新安装。

Sometimes,the above saying will greatly help you!

有时候,上面这句话会对你有很大帮助!

回答by jamesdlin

In case it helps someone else, I encountered an errSecInternalComponenterror with codesignbecause I was running it over an ssh session to my macOS machine. Running the same command from a terminal window on the macOS machine itself worked.

万一它帮助其他人,我遇到了一个errSecInternalComponent错误,codesign因为我是通过 ssh 会话运行它到我的 macOS 机器。从 macOS 机器本身的终端窗口运行相同的命令。

Presumably this is because codesignneeds access to the private key from the login keychain.

大概这是因为codesign需要从登录钥匙串访问私钥。

Running security unlock-keychain login.keychain(as explained by cbracken's answer) from the same session also should work.

从同一会话运行security unlock-keychain login.keychain(如cbracken 的回答所解释)也应该有效。

回答by sahiljain

I had the same issue Found out the problem is with code signing the app.

我有同样的问题发现问题在于代码签名应用程序。

Opened the developer account and accepted the updated agreement and it worked.  

enter image description here

在此处输入图片说明

回答by sunapi386

I ran security unlock-keychain login.keychainand my login password didn't work. So I rebooted, and then just ran Xcode again and it worked. Running the command works as well. Strange issue.

我跑了security unlock-keychain login.keychain,我的登录密码没有用。所以我重新启动,然后再次运行 Xcode 并且它工作了。运行命令也可以。奇怪的问题。

回答by Mohit Tater

As pointed out by @Equilibrium in one of the comments, if you are in command line env. like Jenkins(my case), you might need to pass the password to the security-unlockcommand mentioned in the solutions.

正如@Equilibrium 在其中一条评论中指出的那样,如果您在命令行环境中。像 Jenkins(我的情况)一样,您可能需要将密码传递给解决方案中提到的security-unlock命令。

So instead of using,

所以,而不是使用,

security unlock-keychain login.keychain

use:

用:

security unlock-keychain -p <login-keychain-password> <path-to-login-keychain>

where path-to-login keychain can be $HOME/Library/Keychains/login.keychain(my case) or simply login.keychain

其中路径登录钥匙串可以是$HOME/Library/Keychains/login.keychain(我的情况)或只是login.keychain

回答by Stas S

If trying to sign from ssh run command:

如果尝试从 ssh run 命令进行签名:

security unlock-keychain login.keychain

before trying to sign app bundle

在尝试签署应用程序包之前

or from UI

或从用户界面

Update key access control to "Allow all applications to access this item"

将密钥访问控制更新为“允许所有应用程序访问此项目”

Thx to @Equilibrium and @Jon McClung

感谢@Equilibrium 和@Jon McClung