工程->targes -> build phase-> +run script
-
将下列代码加入.
#update build version ## Get project info buildPlist="${PROJECT_DIR}/${INFOPLIST_FILE}" buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$buildPlist") versionString=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$buildPlist") ## Increment build number for every build if [ "$CONFIGURATION" == "Debug" ] || [ "$CONFIGURATION" == "Release" ]; then ## Increment the buildNumber (A.K.A CFBundleVersion) buildNumber=$(($buildNumber + 1)) /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$buildPlist" fi