views:

576

answers:

2

I was wondering if there is an Xcode or GCC preprocessor symbol for the target name of the application.

For example if I'm building an application called "MonkeyChicken", is there a preprocessor symbol such that

printf( __TARGET_NAME__ )

outputs:

MonkeyChicken
+2  A: 

I don't believe there is any built-in (gcc has no idea what you're building when you compile a file), but you can always create one using GCC_PREPROCESSOR_DEFINITIONS in an xcconfig file (you are using xcconfig, right?) Something like this should work as you indicate above:

GCC_PREPROCESSOR_DEFINITIONS = __TARGET_NAME__=$(PRODUCT_NAME)
Rob Napier
My goodness I'm so glad there's an alternative to that damn build panel. Thanks for your answer.
Justicle
A: 

Is there a way to really have the target name (eg: "Release" or "AdHoc") instead of having to either hardcode it in a build setting or using a #if?

StuFF mc