iOS通过配置脚本实现Archive时自动增加Build构建版本号(Objective-C)

2018.5.2

参考链接:
1.自增build ID配置

1.不区分模式,只要编译成功,Build构建版本号就会增加
#Auto Raise Build Version

plist=${PROJECT_DIR}/${INFOPLIST_FILE}

buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${plist}")

#increment the build number
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${plist}"
2.Release模式下编译成功,Build构建版本号才会增加

一般默认,Archive时才会是release模式

#Auto Raise Build Version

if [ $CONFIGURATION == Release ]; then
echo "Bumping build number..."
plist=${PROJECT_DIR}/${INFOPLIST_FILE}

#check the plist file
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${plist}")
if [[ "${buildNumber}" == "" ]]; then
echo "No build number in $plist"
exit 2
fi

#increment the build number
buildNumber=$(expr $buildNumber + 1)
/usr/libexec/Plistbuddy -c "Set CFBundleVersion $buildNumber" "${plist}"
echo "Bumped build number to $buildNumber"

else
echo $CONFIGURATION " build - Not bumping build number."

fi

你可能感兴趣的:(iOS通过配置脚本实现Archive时自动增加Build构建版本号(Objective-C))