为什么我在 Yosemite 上的 Xcode 6 中收到错误“Command /usr/bin/codesign failed with exit code 1”?

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

Why am I getting the error "Command /usr/bin/codesign failed with exit code 1" in Xcode 6 on Yosemite?

xcodemacoscode-signingosx-yosemite

提问by scb998

I'm using Xcode 6.1, OS X Yosemite preview 8, and I'm getting the following error on code signing my app:

我使用的是 Xcode 6.1、OS X Yosemite preview 8,并且在对我的应用程序进行代码签名时出现以下错误:

Command /usr/bin/codesign failed with exit code 1

命令 /usr/bin/codedesign 失败,退出代码为 1

Reading on Google, it seems to be linked to expired certificates/provisioning profiles. I deleted all of my certificates & profiles, created a new development certificate & profile, installed both, restarted my Mac, and I'm still getting the same error.

在 Google 上阅读,它似乎与过期的证书/配置文件相关联。我删除了我所有的证书和配置文件,创建了一个新的开发证书和配置文件,安装了两个,重新启动了我的 Mac,但我仍然遇到同样的错误。

Can anyone shed some light on how to resolve this problem?

谁能解释一下如何解决这个问题?

采纳答案by scb998

So I've managed to fix the issue for my particular case - in the build settings, instead of automatically detecting the certificate & provisioning profile to use, I manually set them - and it works.

因此,我设法针对我的特定情况解决了该问题 - 在构建设置中,我没有自动检测要使用的证书和配置文件,而是手动设置它们 - 并且它有效。

回答by LMVogel

How about this: Try Xcode -> Preferences -> Accounts -> Choose your account, and then View Details -> Refresh (button on bottom left), Refresh again, restart XCode. Sounds like voodoo but it works for me and my team! (Posting it as answer, because it DOES work, at least sometimes and for some people. Possibly related to the weather ;) )

怎么样:试试 Xcode -> Preferences -> Accounts -> 选择你的账户,然后 View Details -> Refresh(左下角的按钮),再次刷新,重启 XCode。听起来像巫毒教,但它对我和我的团队有用!(将其发布为答案,因为它确实有效,至少有时对某些人来说是有效的。可能与天气有关;))

回答by C. Greene

as of Xcode 6.3.2, here's what I did. from main project view, click on build settings and in the search bar type in certificate, a code signing tab should pop up, I chose "dont sign code". and it worked

从 Xcode 6.3.2 开始,这就是我所做的。从主项目视图中,单击构建设置并在搜索栏中键入证书,应弹出代码签名选项卡,我选择了“不签名代码”。它起作用了

回答by Keith

In my case I was getting this error while trying to build a project I downloaded from Github for my own personal use. I just went to the build settings and told it not to sign the code.

就我而言,我在尝试构建从 Github 下载的项目供我个人使用时遇到此错误。我刚刚进入构建设置并告诉它不要签署代码。

回答by High Performance Coder

Another gotcha I noticed is that codesign will fail if run from an ordinary ssh login session. It has to be run on a MacOSX desktop GUI shell window. This catches me every time, so I've added a line to the build script to print a message about running the script on the MacOSX GUI if codesign fails.

我注意到的另一个问题是,如果从普通的 ssh 登录会话运行,协同设计将失败。它必须在 MacOSX 桌面 GUI shell 窗口上运行。每次都会引起我的注意,因此我在构建脚本中添加了一行,以打印有关在协同设计失败时在 MacOSX GUI 上运行脚本的消息。

回答by Sarat Patel

Delete previous provisional profile and add new provisional profile.restart the machine if still its giving an error like above. when your machine shut off then automatically your device asking for permission then select Confirm and run your code....its working.

删除以前的临时配置文件并添加新的临时配置文件。如果仍然出现上述错误,请重新启动机器。当您的机器关闭时,您的设备会自动请求许可,然后选择确认并运行您的代码......它正在工作。

回答by Jacob Rose

There appears to be a bug in XCode (I'm using 7.1.1) with returning to "Signing: None" after having attempted to sign with an expired identity, resulting in this codesign error even after you've apparently removed the bad signing identity.

XCode 中似乎存在一个错误(我使用的是 7.1.1),在尝试使用过期身份进行签名后返回“签名:无”,即使在您显然删除了错误签名后也会导致此代码签名错误身份。

The project.pbxproj file retains TargetAttributes for the expired identity, and Debug and Release settings both continue to show the following instead of the original empty values:

project.pbxproj 文件保留过期标识的 TargetAttributes,并且 Debug 和 Release 设置都继续显示以下而不是原始的空值:

"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer";

This persists after cmd+alt+shift+K and closing XCode. I fixed it with a git reset (if I hadn't committed before attempting to sign, I'm not sure how I would have found this).

这在 cmd+alt+shift+K 并关闭 XCode 后仍然存在。我用 git reset 修复了它(如果我在尝试签名之前没有提交,我不确定我是如何找到它的)。

回答by Dave Cole

I had to delete all my developer certificates from Keychain Access first, then use the Preferences -> Accounts -> View Details -> Download All approach to successfully re-sign my code.

我必须首先从 Keychain Access 中删除我的所有开发人员证书,然后使用 Preferences -> Accounts -> View Details -> Download All 方法成功重新签署我的代码。