xcode xcodebuild 如何使用命令行签署应用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28395427/
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
xcodebuild how to sign app with command line?
提问by alaslipknot
I am trying to export an ipa using the command line, I can't do that within Xcode because the app is made for a client and I am not a member of his team (I really hope Apple changes that and makes it work like in Xcode 5 :/ )
我正在尝试使用命令行导出 ipa,我无法在 Xcode 中执行此操作,因为该应用程序是为客户制作的,而我不是他的团队成员(我真的希望 Apple 改变这一点并使其像在Xcode 5 :/)
Anyway, I did more research and tried this command:
无论如何,我做了更多的研究并尝试了这个命令:
xcodebuild -exportArchive -archivePath pcdev.xcarchive -exportPath ~/Desktop/playcadeAdHoc.ipa -exportFormat ipa -PROVISIONING_PROFILE= xxxxxxx-8a61-4264-8fe9-0513bd7935e6 -CODE_SIGN_IDENTITY=iPhone Developer:xxxxx
It did export the .ipa but I wasn't able to run it on my phone; I was stuck in the installing state. I went through the logs of the command and I think this one is causing the problem:
它确实导出了 .ipa,但我无法在手机上运行它;我一直卡在安装状态。我查看了命令的日志,我认为这是导致问题的原因:
Checking original app
- /usr/bin/codesign --verify -vvvv /var/folders/ks/gxlbsszj7t58y5n6z8d1hpcm0000gn/T/7F8E1EF2-5238-4EC6-AE74-CDEC6C082A76-2731-00000AE5DF0617E4/games.app Program /usr/bin/codesign returned 1 : [/var/folders/ks/gxlbsszj7t58y5n6z8d1hpcm0000gn/T/7F8E1EF2-5238-4EC6-AE74-CDEC6C082A76-2731-00000AE5DF0617E4/games.app: a sealed resource is missing or invalid file missing: /private/var/folders/ks/gxlbsszj7t58y5n6z8d1hpcm0000gn/T/7F8E1EF2-5238-4EC6-AE74-CDEC6C082A76-2731-00000AE5DF0617E4/games.app/archived-expanded-entitlements.xcent ]
Codesign check fails : /var/folders/ks/gxlbsszj7t58y5n6z8d1hpcm0000gn/T/7F8E1EF2-5238-4EC6-AE74-CDEC6C082A76-2731-00000AE5DF0617E4/games.app: a sealed resource is missing or invalid file missing: /private/var/folders/ks/gxlbsszj7t58y5n6z8d1hpcm0000gn/T/7F8E1EF2-5238-4EC6-AE74-CDEC6C082A76-2731-00000AE5DF0617E4/games.app/archived-expanded-entitlements.xcent
检查原始应用程序
- 在/ usr / bin中/协同设计--verify -vvvv /var/folders/ks/gxlbsszj7t58y5n6z8d1hpcm0000gn/T/7F8E1EF2-5238-4EC6-AE74-CDEC6C082A76-2731-00000AE5DF0617E4/games.app计划的/ usr / bin中/协同设计返回1: /var/folders/ks/gxlbsszj7t58y5n6z8d1hpcm0000gn/T/7F8E1EF2-5238-4EC6-AE74-CDEC6C082A76-2731-00000AE5DF0617E4/games.private/games50000000gn/games1hpcms00000gn/T/7F8E1EF2-5238-4EC6-AE74-CDEC6C082A76-2731-00000AE5DF0617E4/games7/games.private/games500000gn/games.private/games10000000gn T/7F8E1EF2-5238-4EC6-AE74-CDEC6C082A76-2731-00000AE5DF0617E4/games.app/archived-expanded-entitlements.xcent]
协同设计检查失败:/var/folders/ks/gxlbsszj7t58y5n6z8d1hpcm0000gn/T/7F8E1EF2-5238-4EC6-AE74-CDEC6C082A76-2731-00000AE5DF0617E4 缺少/无效的文件/游戏缺少密封/应用程序文件/游戏无效资源密封ks/gxlbsszj7t58y5n6z8d1hpcm0000gn/T/7F8E1EF2-5238-4EC6-AE74-CDEC6C082A76-2731-00000AE5DF0617E4/games.app/archived-expanded-expanded
I am sure that am using the correct provisioning and code signing name, also in Xcode I changed the scheme archive setting to debug instead of release in order to work with adhoc and development identity.
我确信我使用了正确的配置和代码签名名称,也在 Xcode 中我将方案存档设置更改为调试而不是发布,以便使用临时和开发身份。
My experience with Apple tools is very limited so please try to explain the solution as much as possible.
我对 Apple 工具的经验非常有限,所以请尽可能多地解释解决方案。
EDIT:I also tried this method it doesn't gave me any error but still the app is stacked in "installing...":
编辑:我也尝试过这种方法,它没有给我任何错误,但该应用程序仍然堆积在“正在安装...”中:
xcrun -sdk iphoneos PackageApplication ~/Desktop/finalX.xcarchive/Products/Applications/games.app -o ~/Desktop/playcadetest.ipa --sign "iPhone Developer: Name Name (xxxxxxxx)" --embed ~/Desktop/p/adhoc.mobileprovision
Thank you
谢谢
回答by alaslipknot
It turns out that I was using the wrong commands; specifically this part is wrong:
事实证明我使用了错误的命令;特别是这部分是错误的:
-PROVISIONING_PROFILE= xxxxxxx-8a61-4264-8fe9-0513bd7935e6
-CODE_SIGN_IDENTITY=iPhone Developer:xxxxx
The correct one is this:
正确的是这样的:
-exportProvisioningProfile "Provisioning profile full name "
Provisioning profile full nameis the same name that appear in Xcode, not the UDID (I don't know why many people suggested that) also there is no need to specify the signing identity.
Provisioning profile 全名与Xcode 中出现的名称相同,而不是UDID(我不知道为什么很多人建议这样做),也不需要指定签名身份。
Anyway, here is the full command line that is working for me now:
无论如何,这是现在对我有用的完整命令行:
xcodebuild -exportArchive -archivePath myArchive.xcarchive -exportPath myApp.ipa -exportFormat ipa -exportProvisioningProfile "Provisioning profile full name"
NOTE:
笔记:
- I am running this command after copying the archive in a folder
(desktop) then changing the terminal location to that folder (
cd desktop
) and then running the command - Also don't forget to change the provisioning profile based on your archive build configuration (release or debug), you can change that from the scheme setting to either make a debug or a release build.
- 在将存档复制到文件夹(桌面)中,然后将终端位置更改为该文件夹 (
cd desktop
) 然后运行该命令后,我正在运行此命令 - 另外不要忘记根据您的存档构建配置(发布或调试)更改配置文件,您可以将其从方案设置更改为进行调试或发布构建。