Is it possible to read a preprocessor macro from a build script in Xcode?
In my precompiled header I’ve defined a macro like:
#define APIKEY 123abc
In my build script I would like to get access to this macro as a variable so that I can do something with it, e.g.:
echo $APIKEY > outputfile
Yes, it’s possible, but you will need to search the header file it’s
defined in, in order to find it. You could use numerous utilities to do that, butgrepandawkare probably the most straight forward and will work in most trivial cases (you might need more if the constant is a string constant):