I was looking at Apple\'s Lister (for Apple Watch, iOS, and OS X) sample. The sample performs a test for iOS and OS X:
#import
#if
There is no WatchKit or app extension target conditional. But you can create your own per-target conditionals that you use in the same way.
If you look in the "Build Settings" section for any target, there's a section called "Other C Flags". Add an entry for the WatchKit target. If you add something like -DMY_WATCHKIT_FLAG=1
, you can then do #if MY_WATCHKIT_FLAG
in code.
Make your custom flag, well, custom. It's not impossible that Apple might add a flag in the future called something like TARGET_WATCH_APP
or whatever. Use a prefix on the flag name to make it specific to you.