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 Reply to “Easy version numbering in projects”

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.