Reputation: 32207
I would like to trigger a warning only if my TESTING is YES. Is this possible? What I have now doesn't work. What should I do?
BOOL const TESTING = NO;
#if TESTING == YES
#warning don't forget to turn testing to NO before upload
#endif
Based on the answer below, here is what worked for me:
#define _TESTING // COMMENT THIS OUT TO DISABLE TESTING MODE
#ifdef _TESTING
BOOL const TESTING = YES;
#warning don't forget to turn testing to NO for production
#else
BOOL const TESTING = NO;
#endif
Upvotes: 2
Views: 656
Reputation: 3001
Try replacing what you have with
#ifdef TESTING
#warning //... warning here
BOOL const testingBool = YES;
#else
BOOL const testingBool = NO;
#endif
Then, you need to add TESTING as a "Preprocessor Macro" in your Target's Build Settings (see this question for more details on how to do that).
Upvotes: 2