Automatically increment build number (CFBundleVersion)

David wrote this nice little helper that automatically increments the build version every time.

#!/bin/bash
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(echo $buildNumber | sed 's/0*//')
buildNumber=$(($buildNumber + 1))
buildNumber=$(printf "%04d" $buildNumber)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"

In Xcode just head over to “Build Phases” of your target and “Editor” -> “Add Build Phase” -> “Add Run Script Build Phase” there you can just simply use this little script and every time you build your app the build version gets incremented. So at least I can see how many times I build a certain project.

This entry was posted in computer and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *