iOS 构建/ipa 创建不再从命令行工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32763288/
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
iOS builds / ipa creation no longer works from the command line
提问by Mike Vosseller
Overview
概述
Our command line builds (to build and create the .ipa) are no longer working.
我们的命令行构建(构建和创建 .ipa)不再有效。
iTunesConnect has started rejecting builds that use the CODE_SIGN_RESOURCE_RULES_PATH
build setting.
iTunesConnect 已开始拒绝使用CODE_SIGN_RESOURCE_RULES_PATH
构建设置的构建。
If we build WITHOUT that setting the PackageApplication tool (which we use to create the signed .ipa) fails.
如果我们在没有设置的情况下构建 PackageApplication 工具(我们用来创建签名的 .ipa)将失败。
It seems that PackageApplication calls /usr/bin/codesign with resource-rules arguments even if the CODE_SIGN_RESOURCE_RULES_PATH
build setting is excluded
即使CODE_SIGN_RESOURCE_RULES_PATH
排除了构建设置,PackageApplication 似乎也使用资源规则参数调用 /usr/bin/codesign
I suspect the PackageApplication needs to be updated so that it does not call /usr/bin/codesign with resource-rules arguments when the CODE_SIGN_RESOURCE_RULES_PATH
build setting is excluded.
我怀疑 PackageApplication 需要更新,以便在CODE_SIGN_RESOURCE_RULES_PATH
排除构建设置时它不会使用资源规则参数调用 /usr/bin/codesign 。
Has anyone found a solution for this?
有没有人找到解决方案?
Details
细节
We build our app on the command line like this:
我们在命令行上构建我们的应用程序,如下所示:
xcodebuild -workspace myApp.xcworkspace -scheme myApp -sdk iphoneos -configuration AppStoreDistribution OBJROOT=$PWD/build SYMROOT=$PWD/build ONLY_ACTIVE_ARCH=NO 'CODE_SIGN_RESOURCE_RULES_PATH=$(SDKROOT)/ResourceRules.plist'
We create the signed .ipa on the command line like this:
我们在命令行上创建签名的 .ipa,如下所示:
xcrun -log -sdk iphoneos PackageApplication "/Users/mpv/dev/myApp/build/AppStoreDistribution-iphoneos/myApp.app" -o "/Users/mpv/dev/myApp/build/AppStoreDistribution-iphoneos/myApp.ipa" -sign "iPhone Distribution: MyTeam (XXXXXXXXXX)" -embed /Users/mpv/Library/MobileDevice/Provisioning\ Profiles/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.mobileprovision
iTunesConnect is now rejecting our builds with the following error:
iTunesConnect 现在拒绝我们的构建并出现以下错误:
"This bundle is invalid. The Info.plist contains an invalid key 'CFBundleResourceSpecification' in bundle myApp [myApp.app]"
“此捆绑包无效。Info.plist 在捆绑包 myApp [myApp.app] 中包含无效的键 'CFBundleResourceSpecification'”
If we remove the 'CODE_SIGN_RESOURCE_RULES_PATH=$(SDKROOT)/ResourceRules.plist'
bit from the build command then the app is built without the CFBundleResourceSpecification
plist key (which I presume is what we want). The new build command looks like this:
如果我们'CODE_SIGN_RESOURCE_RULES_PATH=$(SDKROOT)/ResourceRules.plist'
从 build 命令中删除该位,那么应用程序将在没有CFBundleResourceSpecification
plist 键的情况下构建(我认为这是我们想要的)。新的构建命令如下所示:
xcodebuild -workspace myApp.xcworkspace -scheme myApp -sdk iphoneos -configuration AppStoreDistribution OBJROOT=$PWD/build SYMROOT=$PWD/build ONLY_ACTIVE_ARCH=NO
The problem now is that the command to build the .ipa fails with the following error:
现在的问题是构建 .ipa 的命令失败并出现以下错误:
error: /usr/bin/codesign --force --preserve-metadata=identifier,entitlements,resource-rules --sign iPhone Distribution: MyTeam (XXXXXXXXXX) --resource-rules=/var/folders/2b/7hylk7nn13dgrl9yyh2wp0lm0000gn/T/zDRRJMkKtQ/Payload/myApp.app/ResourceRules.plist --entitlements /var/folders/2b/7hylk7nn13dgrl9yyh2wp0lm0000gn/T/zDRRJMkKtQ/entitlements_plistIUdGWLYe /var/folders/2b/7hylk7nn13dgrl9yyh2wp0lm0000gn/T/zDRRJMkKtQ/Payload/myApp.app failed with error 1. Output: Warning: usage of --preserve-metadata with option "resource-rules" (deprecated in Mac OS X >= 10.10)!
Warning: --resource-rules has been deprecated in Mac OS X >= 10.10! /var/folders/2b/7hylk7nn13dgrl9yyh2wp0lm0000gn/T/zDRRJMkKtQ/Payload/myApp.app/ResourceRules.plist: cannot read resources
错误:/usr/bin/codesign --force --preserve-metadata=identifier,entitlements,resource-rules --sign iPhone 分发:MyTeam (XXXXXXXXXX) --resource-rules=/var/folders/2b/7hylk7nn13dgrl9yyh2wp0lm0000gn/T /zDRRJMkKtQ/Payload/myApp.app/ResourceRules.plist --entitlements /var/folders/2b/7hylk7nn13dgrl9yyh2wp0lm0000gn/T/zDRRJMkKtQ/entitlements_plistIUdGWLYe /var/folders/7nnlAppyrgtm/var/folders/2b10lAppylhappers/2b/7hylk7nn13dgrl9yyh2wp0lm0000gn/T/zDRRJMkKtQ/ 1. 输出:警告:使用 --preserve-metadata 和选项“resource-rules”(在 Mac OS X >= 10.10 中已弃用)!
警告:--resource-rules 在 Mac OS X >= 10.10 中已被弃用!/var/folders/2b/7hylk7nn13dgrl9yyh2wp0lm0000gn/T/zDRRJMkKtQ/Payload/myApp.app/ResourceRules.plist:无法读取资源
It seems that PackageApplication calls /usr/bin/codesign with resource-rules arguments even if the CODE_SIGN_RESOURCE_RULES_PATH
argument / build setting is excluded.
即使CODE_SIGN_RESOURCE_RULES_PATH
排除了参数/构建设置,PackageApplication 似乎也使用资源规则参数调用 /usr/bin/codesign 。
I think PackageApplication needs to be updated so that it does not call /usr/bin/codesign with resource-rules arguments when the CODE_SIGN_RESOURCE_RULES_PATH
argument / build setting is excluded.
我认为 PackageApplication 需要更新,以便CODE_SIGN_RESOURCE_RULES_PATH
在排除参数/构建设置时,它不会使用资源规则参数调用 /usr/bin/codesign 。
回答by Mike Vosseller
Apple got back to me with a solution. As of Xcode 7 we should use xcodebuild
instead of PackageApplication
to produce the .ipa file.
苹果给我一个解决方案。从 Xcode 7 开始,我们应该使用xcodebuild
而不是PackageApplication
生成 .ipa 文件。
xcodebuild has a new -exportArchive option to create an .ipa that works more like Xcode Organizer.
xcodebuild 有一个新的 -exportArchive 选项来创建一个更像 Xcode Organizer 的 .ipa。
So we should now:
所以我们现在应该:
- build an archive with
xcodebuild archive
- create the .ipa with
xcodebuild -exportArchive
- 建立一个存档
xcodebuild archive
- 创建.ipa
xcodebuild -exportArchive
We now build the archive like this:
我们现在像这样构建档案:
xcodebuild -workspace myApp.xcworkspace -scheme myApp -sdk iphoneos -configuration AppStoreDistribution archive -archivePath $PWD/build/myApp.xcarchive
We now export the .ipa like this:
我们现在像这样导出 .ipa:
xcodebuild -exportArchive -archivePath $PWD/build/myApp.xcarchive -exportOptionsPlist exportOptions.plist -exportPath $PWD/build
These two command create the files build/myApp.xcarchive
and build/myApp.ipa
这两个命令创建文件build/myApp.xcarchive
和build/myApp.ipa
Note that xcodebuild -exportArchive
requires a -exportOptionsPlist
argument that points to a .plist file with export options. For a complete list of what you can put in that plist, run xcodebuild -help
. The minimal contents of the file looks like this:
请注意,它xcodebuild -exportArchive
需要一个-exportOptionsPlist
指向带有导出选项的 .plist 文件的参数。有关可以放入该 plist 的完整列表,请运行xcodebuild -help
. 文件的最小内容如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>app-store</string>
<key>teamID</key>
<string>YOUR_TEN_CHARACTER_TEAM_ID</string>
</dict>
</plist>
In Xcode 9, you now have to specify more details in exportOptions.plist like below:
在 Xcode 9 中,您现在必须在 exportOptions.plist 中指定更多详细信息,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>compileBitcode</key>
<false/>
<key>method</key>
<string>ad-hoc</string>
<key>provisioningProfiles</key>
<dict>
<key>my.bundle.idenifier</key>
<string>My Provisioning Profile Name</string>
</dict>
<key>signingCertificate</key>
<string>iPhone Distribution</string>
<key>signingStyle</key>
<string>manual</string>
<key>stripSwiftSymbols</key>
<true/>
<key>teamID</key>
<string>YOURTEAMID</string>
<key>thinning</key>
<string><none></string>
</dict>
</plist>
回答by Devesh
Steps to make iPA Usig terminal
制作iPA Usig终端的步骤
Clean Project:
清洁项目:
Release
释放
xcodebuild clean -project ProjectPath/myApp.xcodeproj -configuration ReleaseAdhoc -alltargets
Debug
调试
xcodebuild clean -project ProjectPath/myApp.xcodeproj -configuration Debug -alltargets
Archive Project:
存档项目:
Debug
调试
xcodebuild archive -project ProjectPath/myApp.xcodeproj -scheme “myApp” -configuration Debug -archivePath pathForArchiveFolder/myApp.xcarchive
Release
释放
xcodebuild archive -project ProjectPath/myApp.xcodeproj -scheme “myApp” -archivePath pathForArchiveFolder/myApp.xcarchive
Export IPA
出口 IPA
Older Version:This may give A signed resource has been added, modified, or deleted. Error
旧版本:这可能会给已签名的资源添加、修改或删除。错误
xcodebuild -exportArchive -archivePath projectPath/myapp.xcarchive -exportPath projectPath/myApp.ipa -exportFormat ipa -exportProvisioningProfile “provisioning profile”
New version:
新版本:
xcodebuild -exportArchive -archivePath ProjectPath/myapp.xcarchive -exportPath projectPath/myApp.ipa -exportOptionsPlist ProjectFolder/exportPlist.plist
回答by Johannes Fahrenkrug
Here's a quick tip in case you need to create the exportOptions.plist file as part of your build process (maybe Jenkins).
如果您需要在构建过程(可能是 Jenkins)中创建 exportOptions.plist 文件,这里有一个快速提示。
You can use the plutil
tool to turn JSON into a plist. Example:
您可以使用该plutil
工具将 JSON 转换为 plist。例子:
echo "{\"method\":\"app-store\"}" | plutil -convert xml1 -o /tmp/exportOptions.plist -- -
Enjoy!
享受!
回答by Devesh
Go to project folder:
转到项目文件夹:
Archive:
档案:
for DEBUG:
调试:
xcrun xcodebuild -scheme MyApp -configuration Debug archive -archivePath build/MyApp.xcarchive
for Release:
发布:
xcrun xcodebuild -scheme MyApp -configuration Release archive -archivePath build/MyApp.xcarchive
Fetch iPA:
获取 iPA:
xcrun xcodebuild -exportArchive -exportPath build/ -archivePath build/MyApp.xcarchive/
回答by Ved Rauniyar
I have created a project name myFirstApp and the location of the project is Desktop/myFirstApp.
Tested on Xcode
8.3
我创建了一个项目名称 myFirstApp,项目的位置是 Desktop/myFirstApp。经过测试Xcode
8.3
Step 1 -
第1步 -
cd /Users/Ved/Desktop/myFirstApp/
Step 2 -
第2步 -
xcodebuild -scheme myFirstApp archive \
-archivePath /Users/Ved/Desktop/myFirstApp.xcarchive
Step 3 -
第 3 步 -
xcodebuild -exportArchive -exportFormat ipa \
-archivePath "/Users/Ved/Desktop/myFirstApp.xcarchive" \
-exportPath "/Users/Ved/Desktop/myFirstApp.ipa" \
-exportProvisioningProfile "myFirstAppDevProfile"