xcode 自动版本号

xcode创建个新的script放到 Target Dependencies 下面
保证build为整数,只对build版本号更改

#update version
buildPlist="${PROJECT_DIR}/${INFOPLIST_FILE}"
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$buildPlist")
versionString=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$buildPlist")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$buildPlist"

newSubversion=`echo $versionString| awk -F "." '{print $3}'`
newSubversion=$(($newSubversion + 1))
newVersionString=`echo $versionString| awk -F "." '{print $1 "." $2 ".'$newSubversion'" }'`

你可能感兴趣的:(xcode 自动版本号)