나는 애플의 Lister (for Apple Watch, iOS, and OS X) 샘플을보고 있었다. 샘플은 iOS 및 OS X에 대한 테스트를 수행합니다Apple Watch 용 프리 프로세서 매크로?
#import <TargetConditionals.h>
#if (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
@import ListerKit;
#elif TARGET_OS_MAC
@import ListerKitOSX;
#endif
그러나 TARGET_OS_WATCH
또는 유사에 대한 시험이 없습니다. TargetConditionals.h
에서
$ cat /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
/SDKs/iPhoneOS7.1.sdk/usr/include/TargetConditionals.h | grep -i watch
$
, 나는 거기에 알고 :
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 32-bit Windows TARGET_OS_UNIX - Generate code will run under some non Mac OS X unix TARGET_OS_EMBEDDED - Generate code will run under an embedded OS variant of TARGET_OS_MAC TARGET_OS_IPHONE - Generate code will run under iPhone OS which is a variant of TARGET_OS_MAC. TARGET_IPHONE_SIMULATOR - Generate code for running under iPhone Simulator
질문 : 애플의 시계를위한 전처리가 있습니까 TargetConditionals.h
에서 watch
에 대한 Grepping는 더 안타를 제공하지?
나는 ios와 태그 합니다만, 나는이 질문에 대한 정확한 OS 확실하지 않다.
아래 목록은 iPhone의 TargetConditionals.h
에서 컴파일되었습니다. 시뮬레이터 및 OS X (그들은 단지 서로 다른 비트가 1로 설정)과 유사하다 :
#define TARGET_OS_MAC 1
#define TARGET_OS_WIN32 0
#define TARGET_OS_UNIX 0
#define TARGET_OS_EMBEDDED 1
#define TARGET_OS_IPHONE 1
#define TARGET_IPHONE_SIMULATOR 0
질문 : 시계 사용 TARGET_OS_EMBEDDED
합니까? 시계가 일 경우TARGET_OS_IPHONE
을 생략합니까?
[UIApplication sharedApplication]을 호출하는 공유 관리자 클래스가있을 수 있지만 시계에서는 금지되어 있습니다. 이 매크로를 사용하여 호출하거나 덮어 쓸 수 있습니다. – ge0rges