我正在看Apple的Lister(Apple Watch,iOS和OS X)样本.该示例对iOS和OS X执行测试:
#import <TargetConditionals.h>
#if (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
@import ListerKit;
#elif TARGET_OS_MAC
@import ListerKitOSX;
#endif
Run Code Online (Sandbox Code Playgroud)
但是,没有测试TARGET_OS_WATCH或类似.Grepping for watchin TargetConditionals.h不会发出命中:
$ cat /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
/SDKs/iPhoneOS7.1.sdk/usr/include/TargetConditionals.h | grep -i watch
$
Run Code Online (Sandbox Code Playgroud)
从TargetConditionals.h,我知道有:
These conditionals specify in which Operating System the generated code will
run. The MAC/WIN32/UNIX conditionals are mutually exclusive. The EMBEDDED/IPHONE
conditionals are variants of TARGET_OS_MAC.
TARGET_OS_MAC - Generate code will run under Mac OS
TARGET_OS_WIN32 - Generate code will run under …