Rob Agar Rob Agar - 7 months ago 48
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"



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


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