最近想使用xcodebuild加Jenkins实现自动化打包,在查找xcodebuild命令时发现网上发布的编写方式千奇百怪而且大部分没有导出dSYM,在此记录一下自己最后总结出的编写方式(可导出dSYM).
上代码
由于需要在脚本中同时打出多个状态的ipa,所以为了方便我把构建命令放到方法内,代码如下:
scheme configuration exportPath build_plist
setArchive()
{
echo "现在打的是路径是${3}"
xcodebuild clean -workspace ${workspace_path}YunUe.xcworkspace -scheme $1 -configuration $2
xcodebuild archive -workspace ${workspace_path}YunUe.xcworkspace -scheme $1 -configuration $2 -archivePath "${3}/${1}.xcarchive" -sdk iphoneos build DWARF_DSYM_FOLDER_PATH='$(PWD)'
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
rvm use system
xcodebuild -exportArchive -archivePath "${3}/${1}.xcarchive" -exportPath ${3}/${1} -exportOptionsPlist "${4}"
}
参数解释:
configuration 项目编译模式,如:Debug,Release
exportPath IPA和dSYM 的导出路径
build_plist : 配置构建参数的plist文件,格式如下
<?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>enterprise</string>
<key>teamID</key>
<string>xxx</string>
<key>compileBitcode</key>
<false/>
</dict>
</plist>
参数解释
teamID:可登录https://developer.apple.com/account 登录相应账号查看Membership获取
method: app-store、enterprise、ad-hoc、development