Xcode - defining a preprocessor macro for conditional compilation
Asked Answered
S

1

5

I'm using XCode 4, and in my project build settings, I've set :

Preprocessor macros
   Debug   DEBUG;FULL
   Release FULL

and in another target of the same project :

Preprocessor macros
   Debug   DEBUG;LITE
   Release LITE

The two targets are using exactly the same files, except the plist info file that is made distinct.

Then later in my code, I wrote :

#ifdef FULL
    // ###### FULL VERSION
    NSLog(@"test");
    // ###### 
#endif

But the log is never written.

What am I doing wrong ? I don't want (need) to set a value to the FULL statement.

Sporangium answered 5/4, 2011 at 19:36 Comment(0)
S
12

Multiple preprocessor macros are separated by spaces not semicolon. So it should be:

Preprocessor macros
   Debug   DEBUG FULL
   Release FULL

With the semicolon, you're defining a single macro called "DEBUG;FULL". And that won't match your #ifdef.

Stocks answered 5/4, 2011 at 19:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.