0

I have 3 targets. Let's say TargetA, TargetB, and TargetC. I have put in each target a different compiler directive in Targets > Target name > Build Settings > Apple LLVM 7.1 - Custom Compiler Flags > Other C Flags > Debug & Release.

enter image description here

I put -dTargetA on TargetA, -dTargetB on TargetB, -dTargetC on TargetC. And then I have this code on AppDelegate's didFinishLaunchingWithOptions:

#if TargetA
    print ("TargetA");
    #else
    #if TargetB
        print ("TargetB");
        #else
             #if TargetC
             print ("TargetC");
             #else
             print ("Not Recognised");
        #endif
    #endif
#endif

But when I ran it, I see "Not Recognised" on the output console, even though I run from any target. What's wrong? Thanks.

Chen Li Yong
  • 5,459
  • 8
  • 58
  • 124

1 Answers1

0

Oh never mind. Turns out I put it in the wrong place. I should put it in the Swift custom compiler flags, instead of the C or C++ flags. But so many answers told me to put in the C compiler flags...

Chen Li Yong
  • 5,459
  • 8
  • 58
  • 124