问题
I have an iOS Xcode project that has several targets. The number of targets in the project will continue to grow as the project progresses and expands. When I create a new version, it is a pain to have to go through each target and manually create the Archive. I looked into how to archive multiple targets using the command line, but none of the answers spoke to what I was trying to accomplish. Any help and guidance is appreciated.
I believe that the following partial command is part of the solution:
xcodebuild archive
archive: Archive a scheme from the build root (SYMROOT). This requires specifying a workspace and scheme.
回答1:
I suppose you want to build it for CI server Manually If you want to read all the schemes in a xcode project
xcodebuild -list | awk 'p && NF {print \$0";";} /Schemes:/ {p=1}' > schemeList.txt
This will put all your schemes in a text file. Then you have to read the text file manually to retrieve each scheme.
You can use the below command line to produce the archive
xcodebuild -scheme ${schemeName} -sdk iphoneos$sdkVersion -configuration Release clean archive -archivePath ${archivePath}.xcarchive
And then the below xcode command to produce the ipa.
xcodebuild -exportArchive -archivePath ${archivePath}.xcarchive -exportOptionsPlist exportOptions.plist -exportPath ${exportPath}
来源:https://stackoverflow.com/questions/30176007/archive-multiple-ios-xcode-target-in-command-line