tags:

views:

31

answers:

1

I want to have conditional code in my iPhone app depending on configuration (Debug/Release/Distribution). I don’t think Xcode communicates the project configuration somehow to my code, e.g there isn’t a macro or such available, is there?

The best solution I’ve come up with so far: in project settings, for each configuration, define a flag in "Other C flags" like -DDEBUG, -DDISTRIBUTION etc.

Then, in my code, have conditional code with preprocessor macros, like

#ifdef DEBUG
// debug-configuration-specific code here
#endif
#ifdef DISTRIBUTION
// distribution-configuration-specific code here
#endif

Is there a different/better/more elegant way of doing the same?

As to why this is necessary: I am setting up some configuration at runtime depending on configuration. E.g I am working against an HTTP API, and I have a different API endpoint URL for debug and release targets, which I am setting up this way.

A: 

Nope ! That's the official recommended way and I don't know any other.

VdesmedT