Easy version numbering in projects

 

When I start all of my projects, I do a few things to make version numbering easy.

First, I create a Defines.h file that looks something like this:

 

 

#ifdef INFO_PLIST
#define STRINGIFY(_x)        _x
#else
#define STRINGIFY(_x)      # _x
#endif

 

#define STRX(x)           x

#define APP_VERSION_NUMBER   STRINGIFY(1.0.0 b1)
#define CF_BUNDLE_VERSION    APP_VERSION_NUMBER

 

Then,  in the build settings, I set it up like this:

 

Xcode.png

 

Then my Info.plist has:

<key>CFBundleShortVersionString</key>

<string>APP_VERSION_NUMBER</string>

<key>CFBundleVersion</key>

<string>CF_BUNDLE_VERSION</string>

<key>CFBundleGetInfoString</key>

<string>AppName APP_VERSION_NUMBER, Copyright © 2010 Gruby Solutions</string>



 

 

So, I just change 1 value in Info.plist and the version number changes. Granted I could just change Info.plist for each build, but I’d have to change a few items. This becomes even more useful when projects have multiple components. In my projects that have multiple components, I like everything to have the same version number (these aren’t operating systems, so I can require an install of all components as once). With this technique, I just change the Defines.h and all the components get the same version number.

Some people change the APP_VERSION_NUMBER and CF_BUNDLE_VERSION to be different, but this mechanism still makes it easy to change the values.

 

One thought on “Easy version numbering in projects

  1. Pingback: Objective-C/Cocoa Tips | Scott Gruby’s Blog

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the answer to the math equation shown in the picture. Click on the picture to hear an audio file of the equation.
Click to hear an audio file of the anti-spam equation