xcode根据version动态修改build号,如下图,按照步骤点击:New Run Script Phase
build script然后在5处增加如下内容:
versionNumber=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "${INFOPLIST_FILE}")
buildNumber=$(/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "${INFOPLIST_FILE}")
stable=`echo ${versionNumber} |awk -F"." '{print $1}'`
beta=`echo ${versionNumber} |awk -F"." '{print $2}'`
alpha=`echo ${versionNumber} |awk -F"." '{print $3}'`
buildNumber=$(($(($stable<<20))+$(($beta<<8))+$(($alpha<<4))))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
网友评论