STF Jenkins 命令行自动打包上传 testflight/App Store 步骤

fionawei · 2017年10月20日 · 2983 次阅读

一:自动打包命令

xcodebuild 打包基础命令

首先,建议先查看官方帮助文档xcodebuild -help
打包:
xcodebuild -workspace <workspacename> -scheme <schemeName> [-destination <destinationspecifier>]... [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [-showBuildSettings] [<buildsetting>=<value>]... [<buildaction>]...
导出包:
xcodebuild -exportArchive -archivePath <xcarchivepath> -exportPath <destinationpath> -exportOptionsPlist <plistpath>

结合实际项目命令如下:

#打包
xcodebuild archive -workspace Cicada.xcworkspace -scheme "Cicada" -configuration Release -archivePath ${ARCHIVEPATH}/Cicada -quiet

#导出IPA包
xcodebuild -exportArchive -archivePath "${ARCHIVEPATH}/Cicada.xcarchive" -exportPath ${EXPORTPATH}  PROVISIONING_PROFILE_SPECIFIER AppStore  -exportOptionsPlist ${ExportOptionsPlist} -quiet

解释:

  1. workspace: Cicada 是我们项目名,改为自己对应项目名即可
  2. PROVISIONING_PROFILE_SPECIFIER: developer 网站 APP store 对应的 Provisioning Profiles 文件名,下载后双击
  3. exportOptionsPlist:对应 method app-store <?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>uploadBitcode</key> <false/> <key>uploadSymbols</key> <false/> </dict> </plist>

二:自动上传命令

altool 上传基础命令

#验证APP
${altoolpath} --validate-app -f ${filepath} -u username [-p password] [--output-format xml]
#上传APP
${altoolpath} --upload-app -f ${filepath} -u username [-p password] [--output-format xml]

命令解释

  1. altool 命令:首先需要进入 altool 工具所在路径才能执行: ALTOOLPATH=/Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Versions/A/Support/altool
  2. -f file :路径需要具体到.ipa 文件结尾
  3. -u username:AppleID
  4. -p password:账号密码 注意:使用 AppleID 密码上传时若遇到以下报错 “Please sign in with an app-specific password. You can create one at appleid.apple.com” 则说明你的 Apple ID 采用了双重认证密码,上架 iOS App 需要去建立一个专用密码来登入 Apple ID 才能上架。

密码获取步骤:

  1. 登录链接:https://appleid.apple.com/account/manage
  2. 点击 Generate Password…获取密码:

三:命令行汇总

#设置基础路径和信息
ARCHIVEPATH="${WORKSPACE}/iOSArchivePackage"
EXPORTPATH="${WORKSPACE}/outputs"
ExportOptionsPlist="/Users/Shared/Jenkins/workspace/taoism/builds/app-store.plist"
ALTOOLPATH=/Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Versions/A/Support/altool
IPAPATH="${WORKSPACE}/outputs/Cicada.ipa"
APPID="sample@app.com"
APPPASSWORD="samplepassword"

#获取钥匙串和打包电脑密码
security unlock-keychain -p "password" $keychainPath

#clean工程目录
xcodebuild clean -configuration "Release" -alltargets

#导出archive文件
xcodebuild archive -workspace Cicada.xcworkspace -scheme "Cicada" -configuration Release -archivePath ${ARCHIVEPATH}/Cicada -quiet

#导出IPA包
xcodebuild -exportArchive -archivePath "${ARCHIVEPATH}/Cicada.xcarchive" -exportPath ${EXPORTPATH}  PROVISIONING_PROFILE_SPECIFIER profilename  -exportOptionsPlist ${ExportOptionsPlist} -quiet

#验证信息
"${ALTOOLPATH}" --validate-app -f "${IPAPATH}" -u "${APPID}" -p "${APPPASSWORD}" --output-format xml


#上传iTunesConnect
"${ALTOOLPATH}" --upload-app -f "${IPAPATH}" -u "${APPID}" -p "${APPPASSWORD}" --output-format xml

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册