Rantings of an Iron Geek

Automatic Build Number in XCode with Python

I've been using a sed script lately, used a Perl script to embed the svn number into the Get Info while at UGOBE, but never used Python even though it's the language I am much more comfortable with.

While searching for versioning best practices I found this blog by Shiny Frog.  It uses a Python script to get the current svn version and use it for the build number.  Even though I don't like using the svn number for a build number (see Dave Durbin's excellent article for details) it motivated me to switch to Python.  

BTW, here's my preferred versioning scheme:

CFBundleShortVersionString - is the marketing version of the application (e.g., 1.0.0, 1.0.1, 1.1.0, 2.0.0, etc.)

CFBundleVersion - is the build number for the marketing version of the application.  This number increases sequentially for each build of the project.

Here's the Python script that does the work:


from AppKit import NSMutableDictionary

import os

# reading info.plist file

projectPlist = NSMutableDictionary.dictionaryWithContentsOfFile_('Info.plist')

Updating Leopard's Pre-Installed Subversion

OSX Leopard ships with Subversion 1.4.x by default. Since then there have been at least 2 major upgrades.  Here's the how to update Leopard's pre-installed copy of subversion.

I recommend downloading two Subversion tools:

1. The SCPlugin from Tigis.org http://scplugin.tigris.org/

    SCPlugin integrest with the Finder in Mac OS X and provides contextual menu to common svn commands.  Like TortoiseSVN on Windows.

2. Latest build of SVN commandline tools from CollabNet


Step by Step:

1. Download and install the latest universal binary from CollabNet

    The installer puts everything into /opt/subversion and creates symbolic links in /usr/local/bin but this doesn't disable the pre-installed copy in /usr/bin.

2. Open your Terminal and check which version of SVN you are using by typing svn --version. This should say 1.4.x

3. Check which installed instance of SVN the OS is using by typing which svn. This will return the path to the SVN version you are using, which probably is /usr/bin/svn

Getting the accessoryButtonTappedForRowWithIndexPath: to get called.

The accessoryButtonTappedForRowWithIndexPath: is a delegate method from the UITableViewDelegate Protocol.  

Compiling and running on iPhone OS 2.2.1 the accessoryButtonTappedForRowWithIndexPath: method gets called as expected and compiling and running on iPhone 3.0 works as expected. 

However, an issues arrise with compiling for iPhone OS 2.2.1 and running on iPhone 3.0.  Here's what to do:

Step by step:

1. Declare your controller class uses conforms to the UITableViewDelegate Protocol

    @interface MyViewController : UITableViewController <UITableViewDelegate>

2. When creating table cells set the correct attributues to enable a detail disclosure button and clear out the cell's target!

- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath 


    static NSString *CellIdentifier = @"My_Cell";

    TableViewCell *cell = (TableViewCell *)[MyTableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

        cell = [[[TableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];

Incrementing Your Build Number in Xcode

Automatically increment the build number of your project's version string.

In your info.plist you should already have the following:

• CFBundleShortVersionString (e.g., 1.0.0)

• CFBundleVersion (e.g.,

Step by step:

1. Enter your initial version values into the info.plist

Bundle versions string, short: 0.1.0 (CFBundleShortVersionString)

Bundle version: (CFBundleVersion)

2. Select your Target in Xcode

3. Add a new run script build phase:

Project -> New Build Phase -> New Run Script Build Phase

4. Paste the script below into the script box

5. Build your project

version=$(sed -n '

/^[[:blank:]]*CFBundleShortVersionString<\/key>$/ {




}' info.plist)

build=$(sed -n '

/^[[:blank:]]*CFBundleVersion<\/key>$/ {




}' info.plist)

build=$(($build +1))

cp Info.plist 'Backup of Info.plist'

sed '

/^[[:blank:]]*CFBundleVersion<\/key>$/ {

Copyright © 2008-2012 Irongeek Software, LLC.  support@irongeeksoftware.com