ios command/usr/bin/codedesign 失败,退出代码 1- 代码符号错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29242485/
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
command/usr/bin/codesign failed with exit code 1- code sign error
提问by LeleMarieC
I'm currently in the process of submitting my first app to the Apple store. I've completed the following processes
我目前正在向 Apple 商店提交我的第一个应用程序。我已经完成了以下过程
- Obtained a developer account
- Logged into the Member Center to Create an App ID
- Used keychain access to request and receive a distribution certificate
- Obtained a provisioning profile using my id and certificate
- 获得开发者账号
- 登录会员中心创建App ID
- 使用钥匙串访问来请求和接收分发证书
- 使用我的 ID 和证书获得了一个配置文件
When I build the app it runs perfectly in the app simulator and on the actual ipad, however when I switch my app to Archive
on iOS Device i have a major code sign error which i've attached below.
当我构建应用程序时,它可以在应用程序模拟器和实际 ipad 上完美运行,但是当我将应用程序切换到Archive
iOS 设备时,我有一个主要的代码签名错误,我在下面附上了。
codesign /Users/Gaby/Library/Developer/Xcode/DerivedData/RoyalAppInspection-dthvtpxadkslqmhkwdpaqkyujscg/Build/Products/Debug-iphoneos/RoyalAppInspection.app
cd /Users/Gaby/Desktop/RoyalAppInspection
export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
export 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
/usr/bin/codesign --force --sign 79640A11C8D22589BD337496ABB8443581513846 --entitlements /Users/Gaby/Library/Developer/Xcode/DerivedData/RoyalAppInspection-dthvtpxadkslqmhkwdpaqkyujscg/Build/Intermediates/RoyalAppInspection.build/Debug-iphoneos/RoyalAppInspection.build/RoyalAppInspection.app.xcent /Users/Gaby/Library/Developer/Xcode/DerivedData/RoyalAppInspection-dthvtpxadkslqmhkwdpaqkyujscg/Build/Products/Debug-iphoneos/RoyalAppInspection.app
79640A11C8D22589BD337496ABB8443581513846: no identity found Command /usr/bin/codesign failed with exit code 1
I have no idea what to do to fix this, as I've tried to make sure all the other aspects of the process were completed correctly.
我不知道该怎么做才能解决这个问题,因为我已经尝试确保该过程的所有其他方面都正确完成。
One concern i did have was when i clicked the provisioning profile file it would not open and "add to library" wouldn't pop up (i cannot access iphone configuration utility for some reason.) I manually added the .mobileprovision file to my xcode project but i'm thinking this may also be a source of my error.
我确实担心的一个问题是,当我单击配置文件时,它不会打开并且“添加到库”不会弹出(由于某种原因,我无法访问 iphone 配置实用程序。)我手动将 .mobileprovision 文件添加到我的 xcode项目,但我认为这也可能是我错误的根源。
Anyone, can you please help?
任何人,你能帮忙吗?
回答by SAPLogix
The following steps solved the problem for me. I was having the issue where it was not compiling for the device or archiving, working fine for simulator.
以下步骤为我解决了这个问题。我遇到的问题是它没有为设备编译或存档,但在模拟器上工作正常。
- Open keychain access.
- Lock the 'login' keychain.
- Unlock it.
- 打开钥匙串访问。
- 锁定“登录”钥匙串。
- 解锁它。
Clean and build after doing the above steps and everything works fine now.
完成上述步骤后进行清理和构建,现在一切正常。
回答by d4Rk
You almost made it on your own, but in the end there seems to be something wrong with your profile.
您几乎是自己完成的,但最终您的个人资料似乎有问题。
First I would recommend a tool to "look inside" the profile to make sure it's the right one: http://furbo.org/2013/11/02/a-quick-look-plug-in-for-provisioning/
首先,我会推荐一个工具来“查看”配置文件以确保它是正确的:http: //furbo.org/2013/11/02/a-quick-look-plug-in-for-provisioning/
This will just add some more information about the profile, when selecting it in Finder and pressing space (Quick Look).
当在 Finder 中选择它并按空格键(快速查看)时,这只会添加有关配置文件的更多信息。
Check your Xcode Preferences:
检查您的Xcode 首选项:
- Xcode Perferences (CMD + ,)
- Accounts
- Select your account on the left
- Select view details on the bottom right
- Refresh (using the small button on the bottom left)
- Xcode 首选项 (CMD + ,)
- 帐户
- 在左侧选择您的帐户
- 选择右下角的查看详情
- 刷新(使用左下角的小按钮)
Xcode stores the profiles in ~/Library/MobileDevice/Provisioning Profiles
Xcode 将配置文件存储在 ~/Library/MobileDevice/Provisioning Profiles
If your distribution profile is not in there, double click on it.
如果您的分发配置文件不在其中,请双击它。
Then it should appear in that folder, but with a hashed name, e.g. 1edf8f42-fd1c-48a9-8938-754cdf6f7f41.mobileprovision
at this point the Quick Look plugin comes in handy :-)
然后它应该出现在该文件夹中,但带有一个散列名称,例如1edf8f42-fd1c-48a9-8938-754cdf6f7f41.mobileprovision
此时 Quick Look 插件派上用场:-)
Next, check your Project Settings:
接下来,检查您的项目设置:
- select the target (not project) you want to build in Xcode
- switch to build settings
- look for the "Code Signing" section
- check if the correct profile is selected under "Provisioning Profile" => "Release"
- 选择要在 Xcode 中构建的目标(不是项目)
- 切换到构建设置
- 寻找“代码签名”部分
- 检查是否在“配置配置文件”=>“发布”下选择了正确的配置文件
Next, check your Scheme Settings:
接下来,检查您的方案设置:
- select Product menu
- open scheme submenu
- select edit scheme...
- select "Archive" on the left
- Build configuration should be set to "Release"
- 选择产品菜单
- 打开方案子菜单
- 选择编辑方案...
- 选择左侧的“存档”
- 构建配置应设置为“发布”
Next, check the Keychain AccessTrust
settings:
接下来,检查钥匙串访问Trust
设置:
- open keychain access (spotlight => keychain)
- select login
- click on Certificates
- look for
iPhone Distribution: Elena Carrasco (8HE2MJLM25)
on the right - right click, select "Get Info"
- open "Trust" section
- set to "Use System Defaults"
- repeat steps 5 to 7 for
Apple Worldwide Developer Relations Certificate Authority
- 打开钥匙串访问(聚光灯 => 钥匙串)
- 选择登录
- 点击证书
iPhone Distribution: Elena Carrasco (8HE2MJLM25)
在右边找- 右键单击,选择“获取信息”
- 打开“信任”部分
- 设置为“使用系统默认值”
- 重复步骤 5 到 7
Apple Worldwide Developer Relations Certificate Authority
Next, check the Keychain Accessprivate key Access Control
:
接下来,检查Keychain Access私钥Access Control
:
- repeat steps 1 to 4 from previous check
- expand the profile to make your private key visible
- right click on the private key, select "Get Info"
- switch to "Access Control"
- select "Confirm before allowing access"
- use the "+" button to add "codesign" (normally located in
/usr/bin/codesign
)
Hint: if it doesn't show up in the file browser, usecmd + shift + g
to enter the path manually - when using Carthage: add
/usr/bin/productbuild
here as well (thx to DesignatedNerd) - "Save Changes"
- 重复上一次检查的步骤 1 到 4
- 展开配置文件以显示您的私钥
- 右键单击私钥,选择“获取信息”
- 切换到“访问控制”
- 选择“允许访问前确认”
- 使用“+”按钮添加“codesign”(通常位于
/usr/bin/codesign
)
提示:如果文件浏览器中没有显示,请使用cmd + shift + g
手动输入路径 - 使用 Carthage 时:
/usr/bin/productbuild
也在这里添加(感谢DesignatedNerd) - “保存更改”
Hope one of this does trick for you!
希望其中之一对您有用!
Update (4/22/16):
更新 (4/22/16):
I just found a very nice explanation about the whole code sign process (it's really worth reading): https://www.objc.io/issues/17-security/inside-code-signing/
我刚刚找到了一个关于整个代码签名过程的非常好的解释(真的很值得一读):https: //www.objc.io/issues/17-security/inside-code-signing/
回答by Manab Kumar Mal
For me following steps worked:
对我来说,以下步骤有效:
- Quit
Xcode
. - Open
Terminal
. - Typed Command
xattr -rc /Users/manabkumarmal/Desktop/Projects/MyProjectHome
- Open Xcode.
- Cleaned.
- Now worked and No Error.
- 退出
Xcode
。 - 打开
Terminal
。 - 键入命令
xattr -rc /Users/manabkumarmal/Desktop/Projects/MyProjectHome
- 打开 Xcode。
- 清洁。
- 现在工作,没有错误。
回答by Shree
This worked for me. Give it a try:
这对我有用。试一试:
cd ~/Library/Developer/Xcode/DerivedData
xattr -rc .
回答by Jose Ramirez
I had this error in Xcode 8 and Mac OS Sierra. Tried all the above solutions and none worked. This was the only one that worked for me. Open terminal, and type this in:
我在 Xcode 8 和 Mac OS Sierra 中遇到了这个错误。尝试了上述所有解决方案,但没有一个奏效。这是唯一对我有用的方法。打开终端,输入:
cd ~/Library/Developer/Xcode/DerivedData
xattr -c *
回答by Sakthimuthiah
For me "Restarting Mac System" got worked
对我来说,“重新启动 Mac 系统”起作用了
回答by luke
For me, i just cleaned the app and it worked (cmd + shift + k), removing the error. I got the error after updating to swift 2.3.
对我来说,我刚刚清理了应用程序并且它工作正常(cmd + shift + k),消除了错误。更新到 swift 2.3 后出现错误。
回答by orion elenzil
Do everything d4Rk suggests, that is a greatwalk-through. if it still isn't signing, you might have some expired or revoked certificates. I find this can happen when you're working on a team.
做 d4Rk 建议的一切,这是一个很好的演练。如果它仍然没有签名,您可能有一些过期或吊销的证书。我发现当你在一个团队中工作时会发生这种情况。
- quit xcode.
- open Keychain Access.
- in the 'Certificates' section, go through all "iPhone Distribution" certificates and if they're expired or revoked or otherwise invalid, delete them.
- same as 3, but for the 'My Certificates' section.
- re-open xcode and try again.
- 退出 xcode。
- 打开钥匙串访问。
- 在“证书”部分,查看所有“iPhone 分发”证书,如果它们已过期或被撤销或无效,请将其删除。
- 与 3 相同,但用于“我的证书”部分。
- 重新打开 xcode 并重试。
回答by Mujahed Ansari
Open the project into the Xcode.
Select project.app
file and right click on it, select “show in finder” option.
Open terminal and go to the project.app
file path.
在 Xcode 中打开项目。
选择project.app
文件并右键单击它,选择“在查找器中显示”选项。
打开终端并转到project.app
文件路径。
Type the following to commands one by one:
一一输入以下命令:
xattr -lr project.app
xattr -cr project.app
Open the project and run.
打开项目并运行。
回答by LizCiraG
Another reason you may see this error that I haven't seen posted yet, especially if you are using Jenkins, is that your certificate's private key needs "Allow all applications to access this item" selected.
您可能会看到我尚未发布的此错误的另一个原因,尤其是在您使用 Jenkins 时,是您证书的私钥需要选择“允许所有应用程序访问此项目”。
- Open your Mac keychain
- Go to "Certificates" or "My Certificates" under "Category" on the left.
- Find the cert you're trying to sign with, and click the little grey triangle on the left of the certificate to reveal the associated private key.
- Left/ double-click the private key and select "Get Info."
- Toggle from "Attributes" to "Access control"
- Select "Allow all applications to access this item" and save changes.
I maintain a large cluster of Mac mini nodes as part of a centralized Jenkins CI system, and this can come up.