Xcode-Increment build number only during ARCHIVE?

后端 未结 3 1365
醉梦人生
醉梦人生 2020-12-12 12:01

I have found a few other posts that show how to add a script to increment the build number with a script:

Better way of incrementing build number?

Xcode proj

3条回答
  •  清歌不尽
    2020-12-12 12:38

    Add the following script, as in the example listed in the first link that you posted, BUT do it twice. Once at the beginning of the build and once at the end:

    if [ $CONFIGURATION == Release ]; then
        echo "Bumping build number..."
        plist=${PROJECT_DIR}/${INFOPLIST_FILE}
    
    # increment the build number (ie 115 to 116)
        buildnum=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${plist}")
        if [[ "${buildnum}" == "" ]]; then
            echo "No build number in $plist"
            exit 2
        fi
    
        buildnum=$(expr $buildnum + 1)
        /usr/libexec/Plistbuddy -c "Set CFBundleVersion $buildnum" "${plist}"
        echo "Bumped build number to $buildnum"
    
    else
        echo $CONFIGURATION " build - Not bumping build number."
    fi
    

    Many thanks to the authors of the questions that you have linked to in your question for the information that got me started on this answer!

提交回复
热议问题