Skip to content

Recipe: Automatic Version Number, Build Number & Build Date Handling | MacIndie

I found this helpful “recipe” for setting up automatic build versioning in Xcode…

Dealing with build and version numbers in applications whether for Desktop MacOSX or iPhone applications always seems like a bit of a black art, here’s the short version of how to set up a consistent and maintainable system for dealing with version numbers in Xcode.

via Recipe: Automatic Version Number, Build Number & Build Date Handling | MacIndie.

I did a couple things differently – mainly I just didn’t set up the “Versioning System” setting (let me know if you know of problems w/ doing this):

  • Add a “Versioning System” item, and set its value to “apple-generic”

I didn’t want to have to run agvtool next-version whenever I needed to update my Bundle version. I’ve used that on other projects and it’s just kinda a pain to have to run a command line command to update it. Too easy to forget, etc.

I ran it w/o that setting and logged out the settings when the app runs like this:

[sourcecode]

-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];

NSString *appVersionNumber = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
NSString *buildNumber = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBuildNumber"];
NSString *buildDateString = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBuildDate"];

NSLog(@"%@ %@ %@", appVersionNumber, buildNumber, buildDateString);
}

[/sourcecode]

The output looked like this:

[Session started at 2011-01-18 10:52:15 -0600.]
2011-01-18 10:52:16.423 BuildNumber[33096:207] 1.0 28 Tue Jan 18 10:45:26 CST 2011