6

I have a app that has multiple targets. Each target has different features. Where and how do I define complier flags so that when I build each target will only have the features that I assign to it.

For instance I like to do something like this.

#ifdef APP1

#define FEATURE_A
#define FEATURE_B

#elif APP2

#define FEATURE_B

#else

#endif

Where would I put #define APP1 or #define APP2. APP1 and APP2 are the bundle IDs of the apps. I would like to do it so that the definitions are not defined dynamically when the application runs (i.e. should not be in an if statement), but rather set when I build the application.

Any suggestions?

Thanks.

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
David
  • 14,205
  • 20
  • 97
  • 144
  • Possible duplicate of [Swift: how to use PREPROCESSOR Flags (like \`#if DEBUG\`) to implement API keys?](https://stackoverflow.com/questions/38813906/swift-how-to-use-preprocessor-flags-like-if-debug-to-implement-api-keys) – zenglekidd Jun 07 '18 at 15:03

1 Answers1

9

Put corresponding definition in target's settings, 'Preprocessor Macros' section.

hoha
  • 4,418
  • 17
  • 15