ytpm
ytpm

Reputation: 5150

#define in .pch file is not working

I'm trying to define the type of the build by using those 3 variables, but for some reason, it always uses the first one. Any ideas?

// Pay attention: only ONE of these modes MUST be chosen.
//
//
#define DEVELOPMENT 0
#define PRODUCTION 1
#define STORE 0

This is how I use it:

#ifdef DEVELOPMENT
    NSLog(@"Development version built.");
#elif STORE
    NSLog(@"Store version built.");
#else
    NSLog(@"Distribution version built.");
#endif

It's always entering the first ifdef..

Upvotes: 0

Views: 537

Answers (1)

Soberman
Soberman

Reputation: 2596

I got what you want to do. You have to do it a liiiitle bit different. You have to do it like this:

#if DEVELOPMENT
    NSLog(@"Development version built.");
#elif STORE
    NSLog(@"Store version built.");
#else
    NSLog(@"Distribution version built.");
#endif

Bacause as @EDUsta has stated, #ifdef checks if this macro is defined at all. If yes - then it will be evaluated to true. In your case you have to check for value, so you have to use #if.

Upvotes: 3

Related Questions