Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode-Increment build number only during ARCHIVE?

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 project's "Build number"

Can Xcode insert the version number into a library's filename when building?

But what I want to do, is only increase the build number when I use ARCHIVE (both before and after).

Example: If current build number is 21, then when I choose Product > Archive the build number will be increased to 22, it will go through its process of building and creating the Archive file with the build number of 22, and then when it is finished archiving, it will increase the build number to 23.

like image 712
jsherk Avatar asked Mar 24 '12 21:03

jsherk


1 Answers

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!

like image 130
lnafziger Avatar answered Oct 10 '22 11:10

lnafziger