一讥邻、構(gòu)建一個(gè)自由風(fēng)格的軟件項(xiàng)目
二、配置代碼工程
三院峡、編寫shell(
抽離變量:包名兴使、teamId、構(gòu)建類型(正式/測(cè)試撕予、apiKey鲫惶、apiIssuer、projectName实抡。
準(zhǔn)備兩個(gè)目錄:ipa導(dǎo)出目錄欠母、archive生成目錄
準(zhǔn)備exportOption:新增adhocExportOption/ExportOptions.plist以及appStoreExportOptions/ExportOptions.plist
)
shell的邏輯:
1.替換appId。
2.替換export配置里的teamId
adhocEntitlementsPath="exportOption/adhocExportOption/ExportOptions.plist"
appStoreEntitlementsPath="exportOption/appStoreExportOptions/ExportOptions.plist"
/usr/libexec/PlistBuddy -c "Set :teamID '${kehuTeamId}'" ${adhocEntitlementsPath}
/usr/libexec/PlistBuddy -c "Set :teamID '${kehuTeamId}'" ${appStoreEntitlementsPath}
3.替換Info.list里的資料(teamId吆寨、icloundId赏淌、描述)
LC_CTYPE=C sed -i '' "s/PRODUCT_BUNDLE_IDENTIFIER = ${appId}/PRODUCT_BUNDLE_IDENTIFIER = ${kehuAppId}/" ${projectPath}
LC_CTYPE=C sed -i '' "s/DevelopmentTeam = ${teamId}/DevelopmentTeam = ${kehuTeamId}/" ${projectPath}
LC_CTYPE=C sed -i '' "s/DEVELOPMENT_TEAM = ${teamId}/DEVELOPMENT_TEAM = ${kehuTeamId}/" ${projectPath}
/usr/libexec/PlistBuddy -c "Set :com.apple.developer.icloud-container-identifiers:0 'iCloud.${kehuAppId}'" ${entitlementsPath}
/usr/libexec/PlistBuddy -c "Set :com.apple.developer.ubiquity-container-identifiers:0 'iCloud.${kehuAppId}'" ${entitlementsPath}
/usr/libexec/PlistBuddy -c 'Add :NSAllowsLocalNetworking string "app不會(huì)連接到您所用網(wǎng)絡(luò)上的設(shè)備,只會(huì)檢測(cè)與您本地網(wǎng)關(guān)的連通性"' ${infoPath}
/usr/libexec/PlistBuddy -c 'Add :NSLocalNetworkUsageDescription string "app不會(huì)連接到您所用網(wǎng)絡(luò)上的設(shè)備啄清,只會(huì)檢測(cè)與您本地網(wǎng)關(guān)的連通性"' ${infoPath}
4.打包archive
# 清理工程
echo '/// 開始清理'
xcodebuild clean -configuration ${development_mode} -quiet || exit
echo '/// 清理完成'
# 生成archive
xcodebuild \
archive -workspace ${projectName}.xcworkspace \
-scheme ${projectName} \
-configuration ${development_mode} \
-allowProvisioningUpdates \
-archivePath ${exportAchivePath} -quiet || exit
echo '/// archive完成'
5.導(dǎo)出ipa
# 導(dǎo)出ipa
xcodebuild -exportArchive -archivePath ${archivePath} \
-configuration ${ipaMode} \
-exportPath ${exportIpaPath} \
-exportOptionsPlist ${exportOptionsConfig} \
-allowProvisioningUpdates \
-quiet || exit
echo '/// ipa包已導(dǎo)出'
6.上傳ipa
# 上傳ipa
if [ ${ipaType} == ${appstore} ]
then
echo "appstore-ipa"
xcrun altool --upload-app -f ${exportIpaPath}/${projectName}.ipa -t iOS --apiKey ${apiKey} --apiIssuer ${apiIssuer} --verbose
echo '/// 發(fā)布ipa包完成 '
elif [ ${ipaType} == ${adhoc} ]
then
echo "adhoc-ipa"
curl -F "file=@${exportIpaPath}/${projectName}.ipa" -F "uKey=" -F "_api_key=" https://qiniu-storage.pgyer.com/apiv1/app/upload
else
echo "打包類型錯(cuò)誤"
fi
7.設(shè)置鑰匙串中對(duì)應(yīng)的開發(fā)者證書六水,企業(yè)開發(fā)證書,允許所有應(yīng)用程序訪問(wèn)此項(xiàng)目
8.自動(dòng)上傳ipa支持兩種模式
1)apikey
2)專有密碼
9.手動(dòng)打包
1)安裝p12
2)安裝對(duì)應(yīng)的mobileprovision
3)和自動(dòng)簽名不一樣的是,需要修改導(dǎo)出配置文件掷贾。新增包名和對(duì)應(yīng)的證書睛榄,簽名模式改成手動(dòng)