from the reference How to handle multiple targets in XCode using swift language? and https://www.appcoda.com/using-xcode-targets/
I have created three targets, each target having different bundle ids and app icons. I have also added different flag to the "Other swift flags" - > Custom swift flag section
like
for first target I added "-DGOLD" , for second target I added "-DSILVER" and for third target I added "-DPLATINUM".
In the AppDelegate I wrote a code
#if GOLD
print ("Gold")
#elseif SILVER
print ("Silver")
#else
print ("Platinum")
#endif
FYI, I am using Xcode 8.3
I tried to run the first target, I always getting "Platinum". Please provide me how to get the flags correctly
I am working with Xcode 9. I am having same problem and looked for an answer for a few hours and finally found the solution. At each Target, Build Settings -> Other Swift Flags, I added the wanted flag like this:
Target1 -> -DTARGET1
Target2 -> -DTARGET2
Then in my code used:
#if TARGET1
//
#elseif TARGET2
//
#endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With