This is a great Copy-Paste solution for every solo iOS Developer. It automatically increases the build number of your Xcode project every time you Run your program.
Two Facts:
- You now have a reason to have a build number.
- You will spend less than a minute on this. And never worry about it again.
Go to your Project’s Build Phases tab, and click the + button. Choose New Run Script Build Phase then drag the Phase to be second (after Target Dependencies).
In the space after the shell’s /bin/bash, copy this:
<code>#!/bin/bash bN=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE") bN=$((0x$bN)) bN=$(($bN + 1)) bN=$(printf "%X" $bN) /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $bN" "$INFOPLIST_FILE"</code>
Works like a charm. Just make sure your build number starts as “1″ and not “1.0″. This great solution was originally posted by RobertL on Stack Overflow but I liked it so much I’m sharing it!
I think this would be particularly powerful if cleverly extended to work with version control.
Leave a Reply