Automatically increment your projects in Xcode

For quite a while, I’ve been trying to figure out how to get my project to automatically increment every time I build and also tie them to our SVN repository. I’ve been using for most of my projects now and thought I’d share it. If you are looking for a quick example, I have a project that uses this on github: https://github.com/brcimo/ScoreTracker

Follow these steps for projects you’ve created:

1.  In Build Phases add a script, click on add build phase and choose add run script.

2.  Copy and paste the following script in the new script:

buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" ${PROJECT_DIR}/$INFOPLIST_FILE)
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" ${PROJECT_DIR}/$INFOPLIST_FILE

REV=`/opt/subversion/bin/svnversion -nc ${PROJECT_DIR} | /usr/bin/sed -e 's/^[^:]*://;s/[A-Za-z]//'`
echo "BUILD_NUMBER = $REV" > ${PROJECT_DIR}/buildnumber.xcconfig

APPVERSION="`/usr/libexec/PlistBuddy -c \"Print :CFBundleVersion\" \"$CODESIGNING_FOLDER_PATH/Info.plist\"`"
SETTINGSBUNDLEPATH="$CODESIGNING_FOLDER_PATH/Settings.bundle/Root.plist"

/usr/libexec/PlistBuddy -c "Set :PreferenceSpecifiers:0:Title My App Title - build:'$APPVERSION' revision:'$REV'" "$SETTINGSBUNDLEPATH"

3.  Make sure you have SVN installed, if you don’t, check out this post: http://www.richards-blog.com/html/?p=368
Alternatively, you can take out the SVN revision, just delete the part relating to $SETTINGSBUNDLEPATH.

4. Add a Setting Bundle to your app if you don’t already have one, and name it Settings.bundle(that’s the default name).

5.  The script above will write the latest value for CFBundleVersion and the last SVN build number in your apps Settings Bundle.

6.  In the project summary page, change Build to “0″, no decimals.

7.  Run it – Magic!

So Cal Code Camp

For those waiting, here is the post with my notes and the project we built today at code camp. You can download the file here. Thank you all for coming. Also, please let me know what you thought of the presentation.

Best Xcode error messages

I’ve had several messages that Xcode has popped up that I thought are pretty funny, so I’m posting them here.

iPad game

Well, a few days ago, I started to make an app for the iPad, a game of course. It’s going to be a new version of Snake Ace called Glow Snake. The main change is in the graphics, It’s being done in a neon glow style, very cool!

More about Cave Balls

First, both versions of Cave Balls have been updated, 1.2. I put in the latest version of OpenFeint and I updated the ads for the free version and I added a menu link to my other games in the paid version. Also, I fixed some minor bugs.

Also, if you are interested, here’s a link to the facebook fan page: http://www.facebook.com/pages/Cave-Balls-Fan-Page/344081052237

So, check it out if you haven’t already, cool.

How many downloads for Cave Balls?

Well, I always wonder about all these apps and how many downloads they get, so I thought I’d let people know how many mine has been downloaded. Here’s it is:
Cave Balls since February 24th 2010
2,600

The highest for a single day so far has been 437. Also, I expect things to pick up quite a bit soon – wink. wink. nudge. nudge.

Well, we’ll see.

Cave Balls Pro

Yea! The paid version of Cave Balls is out now, here’s the link: http://itunes.apple.com/us/app/cave-balls-pro/id357010794?mt=8

It’s the same as Cave Balls, without ads.

Follow

Get every new post delivered to your Inbox.