Show Build-Information in your iOS App About Panel
Build . iOSSometimes it might be useful to have an exact piece of information about what version of an app you have currently running. Especially if you have a decent Testing-Group, it is important to track the versions in which a bug appears. The goal of this post is to achieve a info panel like this in your application.
You get the Application version (from the Application Bundle), the Repository Revision and the Date of the last Commit.
Picture 1: Example Application About Dialog
We are using here the build-in functions of subversion to update given keywords with the repository information. More about this topic here. There is also a way to use this method with git, but i did not test it yet. You may find out more about this here
The first step is to create a File-Template you can import in your code, with which you can access all the necessary details:
#define APP_VERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] #define APP_EXECUTABLE [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleExecutable"] #define APP_NAME [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"] #define APP_BUILD_REVISION @"$Rev$" #define APP_BUILD_DATE @"$Date$" #define APP_LAST_AUTHOR @"$Author$"
Code 1: version.h template
The next step is to tell Subversion to replace the placeholder with the subversion values.
You can do this with setting the subversion keyword for that file.
After that, with every commit of the file “version.h” the values will be updated.
svn propset svn:keywords 'Revision Author Date' version.h
Code 2: version.h template
The very last step is to make sure, that “version.h” will be updated each time you make a change to your application. Assuming you build your app every time you made a change, you can use the functions, build into Xcode to force an update on “version.h”. We use the trick, that every change on the propsets of “version.h” is equal to a file modification itself.
So we create a small bash script, setting the propset “build” to a new value. After that, “version.h” needs to be commited as a new version.
#!/bin/sh DATE=`date` HOST=`hostname` svn propset build "$HOST $DATE" Version.h
Code 3: buildUpdate.sh
Now we need to add the run of “buildUpdate.sh” to our Build-Cycle. (Picture 2 & Picture 3).
Picture 2: Project Target Settings
After a successful commit, the file “version.h” will look something like this:
#define APP_VERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] #define APP_EXECUTABLE [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleExecutable"] #define APP_NAME [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"] #define APP_BUILD_REVISION @"$Rev: 1047 $" #define APP_BUILD_DATE @"$Date: 2011-01-21 18:53:38 +0100 (Fri, 21 Jan 2011) $" #define APP_LAST_AUTHOR @"$Author: phaus $"
Code 4: updated version.h
You might modify the output (e.g. filter out the $s or reformat the date) to get a more stylish output.
Related
Archives
- August 2025
- November 2023
- February 2023
- January 2023
- April 2020
- January 2018
- December 2017
- May 2017
- February 2016
- September 2015
- December 2014
- August 2014
- June 2014
- March 2014
- February 2014
- September 2013
- August 2013
- July 2013
- November 2012
- October 2012
- September 2012
- June 2012
- May 2012
- April 2012
- March 2012
- February 2012
- January 2012
- December 2011
- November 2011
- October 2011
- August 2011
- July 2011
- June 2011
- May 2011
- January 2011
- August 2010
- July 2010
- June 2010
- May 2010
- January 2010
- November 2009
- October 2009
- September 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- September 2006
- June 2006
- May 2006
- April 2006
- March 2006
- February 2006
- January 2006



Leave a Reply