I am working on a project with multiple targets,
I have a preprocessor macro in build settings:
PRODUCT_NAME=\@\"$PRODUCT_NAME\"
now in AppName-Prefix.pch I have defined the $PRODUCT_NAME as:
#define ACTIVE_PRODUCT PRODUCT_NAME
how can I check if ACTIVE_PRODUCT is equal to a string?
I want to do something like this e.g.
if ACTIVE_PRODUCT == @"Product 1"
#define MY_VAR @"Test 1
#endif
if ACTIVE_PRODUCT == @"Product 2"
#define MY_VAR @"Test 2
So I can use MY_VAR in my code depending on the $PRODUCT_NAME
Please assist!
regards,
Bill.
I think there’s a previous question for that, and the answer seems to be that it’s not possible (see the comp.lang.c FAQ). What I try to do is avoid the preprocessor as soon as possible, moving all processing to Objective-C. So instead of
#definingyour variables, you may set a regular Objective-C variable and continue processing in Objective-C:And later:
Of course this assumes that you only need
MyVarin source code, not in resources like plists.