自动打包 ipa 并上传到蒲公英测试平台的 shell 脚本。
Archive
1 2 3 4 5 6 7
| xcodebuild archive \ -quiet -workspace PROJECT_WORKSPACE_FILE_PATH \ -scheme SCHEME \ -configuration CONFIGURATION \ -destination generic/platform=iOS \ -archivePath ARCHIVE_PATH
|
使用 $ xcodebuild -list
命令查看 Targets、Build Configurations 和 Schemes:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| $ xcodebuild -list Information about project "TempProjectOC": Targets: TempProjectOC TempProjectOCTests TempProjectOCUITests
Build Configurations: Debug Release
If no build configuration is specified and -scheme is not passed then "Release" is used.
Schemes: TempProjectOC
|
Export ipa
1 2 3 4 5
| xcodebuild \ -exportArchive \ -archivePath XCARCHIVE_FILE_PATH \ -exportPath EXPORT_IPA_PATH \ -exportOptionsPlist EXPORT_OPTIONS_PLIST_PATH
|
Upload to pgyer
使用 crul 命令上传 App 示例:
1
| $ curl -F "file=@/tmp/example.ipa" -F "_api_key=API_KEY" https://www.pgyer.com/apiv2/app/upload
|
完整的 shell 脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| #!/bin/bash
XCWORKSPACE_PATH="/Users/wy/Develop/Project/Temp/TempProjectOC/TempProjectOC.xcworkspace" SCHEME="TempProjectOC"
ARCHIVE_PATH="/Users/wy/Desktop/archive.xcarchive"
EXPORT_PATH="/Users/wy/Desktop/TPOC"
EXPORTOPTIONSPLIST_PATH="/Users/wy/Develop/Project/Temp/ExportOptions.plist"
PGYER_API_KEY="API_KEY"
green=`tput setaf 2` reset=`tput sgr0`
echo "${green}Xcode archiving...${reset}"
xcodebuild archive \ -quiet \ -workspace ${XCWORKSPACE_PATH} \ -scheme ${SCHEME} \ -configuration Release \ -destination generic/platform=iOS \ -archivePath ${ARCHIVE_PATH} \ || { exit 1; }
echo '' echo "${green}Exporting ipa...${reset}"
xcodebuild \ -exportArchive \ -archivePath ${ARCHIVE_PATH} \ -exportPath ${EXPORT_PATH} \ -exportOptionsPlist ${EXPORTOPTIONSPLIST_PATH} \ || { exit 1; }
echo '' echo "${green}Uploading ipa...${reset}"
curl -F "file=@${EXPORT_PATH}/${SCHEME}.ipa" \ -F "_api_key=${PGYER_API_KEY}" \ https://www.pgyer.com/apiv2/app/upload
|
参考
man xcodebuild
how-to-change-the-output-color-of-echo-in-linux
Shell 教程
[iOS] 从零开始写个自动打包 IPA 脚本
蒲公英 API 文档
Google, …