Last active
July 6, 2019 08:02
-
-
Save MadeBugs/78929ccf37c4e68fc315e376439a8b64 to your computer and use it in GitHub Desktop.
xcode build version 自增
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ $CONFIGURATION == Debug ]; then | |
echo "当前为 Release Configuration,开始自增 Build" | |
plist=${INFOPLIST_FILE} | |
buildnum=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${plist}") | |
if [[ "${buildnum}" == "" ]]; then | |
echo "Error:在Plist文件里没有 Build 值" | |
exit 2 | |
fi | |
buildnum=$(expr $buildnum + 1) | |
/usr/libexec/PlistBuddy -c "Set CFBundleVersion $buildnum" "${plist}" | |
echo "开始自增 Version 最后一位" | |
versionNum=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plist}") | |
thirdPartVersonNum=`echo $versionNum | awk -F "." '{print $3}'` | |
thirdPartVersonNum=$(($thirdPartVersonNum + 0)) | |
newVersionStr=`echo $versionNum | awk -F "." '{print $1 "." $2 ".'$thirdPartVersonNum'" }'` | |
/usr/libexec/PlistBuddy -c "Set CFBundleShortVersionString $newVersionStr" "${plist}" | |
else | |
echo $CONFIGURATION "当前不为 Release Configuration" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment