在IOS提审过程中,要求需要build号版本比现在有的版本号要大。每次release的时候需要去增加Build号,有时候难免忘记。所以添加一个打包脚本,每次release的时候自动build号加1。version为1.1.build号。
添加脚本方式为选中项目-》target-》Build Phases-》+RunScript。将下面脚本拷贝放到里面去。
if [ $CONFIGURATION == Release ]; then
echo "Bumping build number..."
plist=${PROJECT_DIR}/${INFOPLIST_FILE}
buildnum=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${plist}")
if [[ "${buildnum}" == "" ]]; then
echo "No build number in $plist"
exit 2
fi
buildnum=`echo $buildnum +1|bc`
/usr/libexec/Plistbuddy -c "Set CFBundleVersion $buildnum" "${plist}"
/usr/libexec/Plistbuddy -c "Set CFBundleShortVersionString 1.1.$buildnum" "${plist}"
echo "Bumped build number to $buildnum"
else
echo $CONFIGURATION " build - Not bumping build number."
fi