Xcode打開(kāi)項(xiàng)目勾選自動(dòng)簽名客叉,設(shè)置Team和Bundle Identifier
等待Xcode自動(dòng)下載安裝Certificates和Provisioning Profile
確認(rèn)mac里已經(jīng)安裝開(kāi)發(fā)者證書(shū)Certificates和Provisioning Profile
打開(kāi)[鑰匙串訪問(wèn)>登陸>我的證書(shū)>Apple Development...]獲取組織單位(teamID)
將下面代碼保存為shell文件域慷,修改配置參數(shù)后,放到項(xiàng)目根目錄執(zhí)行
# 配置打包參數(shù)
workspace="配置workspace文件名(project_name.xcworkspace)"
scheme="配置項(xiàng)目target名稱(chēng)(target_name)"
teamID="配置teamID"
# 配置上傳參數(shù)
user="配置Apple ID"
pass="配置App-Specific Passwords"
# 清理項(xiàng)目
project_path=$(cd `dirname $0`; pwd)
cd $project_path
xcodebuild clean -workspace $workspace -scheme $scheme
# 創(chuàng)建xcarchive
archiveFilename=(`date +%Y_%m_%d_%H_%M_%S`)
package_dir="package"
mkdir $package_dir
archivePath="$project_path/$package_dir/$archiveFilename"
xcodebuild archive -workspace $workspace -scheme $scheme -archivePath $archivePath -configuration Release
# 創(chuàng)建ipa
cd $package_dir
exportOptionsPlist="ExportOptions.plist"
echo "<?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>generateAppStoreInformation</key>
<false/>
<key>manageAppVersionAndBuildNumber</key>
<true/>
<key>method</key>
<string>app-store</string>
<key>signingStyle</key>
<string>automatic</string>
<key>stripSwiftSymbols</key>
<true/>
<key>teamID</key>
<string>$teamID</string>
<key>uploadSymbols</key>
<true/>
</dict>
</plist>
" > ${exportOptionsPlist}
xcodebuild -exportArchive -archivePath "$archivePath.xcarchive" -exportPath $archivePath -exportOptionsPlist $exportOptionsPlist
# 上傳ipa
xcrun altool --upload-app -t ios -f $archivePath/*.ipa -u $user -p $pass