Rob Agar Rob Agar - 5 months ago 36
iOS Question

Info.plist value as C++ #define

In a C++ iOS project (or any other Mac OS), is there a simple way of making a value available both to the Info.pList settings, and to the code in the form of a preprocessor macro?

Ideally, I would like to have something like this

C++ code:

#define MY_VERSION_STRING "1.0"


Info.pList

CFBundleVersion: ${MY_VERSION_STRING}


Or alternatively, is there a way of getting values from the .pList in c++? (Without manually parsing the .pList as xml.)

Answer

Probably not the best solution, but you could use the /usr/libexec/PlistBuddy utility in a build script to generate a .h file containing a define with a value extracted from the plist.

To output a value from a plist:

/usr/libexec/PlistBuddy -c 'Print :Path:To:Key' filename.plist