What precompiler tag to determine tvOS

Obviously we need to use precompiler conditions to add and remove certain libraries.


However, not sure what we should use?


I know I could create my own precompiler variable in build settings, but this wouldn't tie in to a specific device.

Future proofing it.

Accepted Reply

Looks like, not surprisingly, it's TARGET_OS_TV.


From TargetConditionals.h for tvOS 9.0 Simulator:


/
*    gcc based compiler used on Mac OS X
*/
#if defined(__GNUC__) && ( defined(__APPLE_CPP__) || defined(__APPLE_CC__) || defined(__MACOS_CLASSIC__) )
    #define TARGET_OS_MAC               1
    #define TARGET_OS_WIN32             0
    #define TARGET_OS_UNIX              0
    #define TARGET_OS_IPHONE            1
    #define TARGET_OS_IOS               0
    #define TARGET_OS_WATCH             0
    #define TARGET_OS_TV                1
    #define TARGET_OS_SIMULATOR         1
    #define TARGET_OS_EMBEDDED          0
    #define TARGET_IPHONE_SIMULATOR     TARGET_OS_SIMULATOR / deprecated */
    #define TARGET_OS_NANO              TARGET_OS_WATCH / deprecated */
...

Replies

These are normally found in TargetConditionals.h, however I haven't got Xcode 7.1 beta yet, so I cannot tell you what values to use.


If you have Xcode 7.1, it should be easy to find.

Looks like, not surprisingly, it's TARGET_OS_TV.


From TargetConditionals.h for tvOS 9.0 Simulator:


/
*    gcc based compiler used on Mac OS X
*/
#if defined(__GNUC__) && ( defined(__APPLE_CPP__) || defined(__APPLE_CC__) || defined(__MACOS_CLASSIC__) )
    #define TARGET_OS_MAC               1
    #define TARGET_OS_WIN32             0
    #define TARGET_OS_UNIX              0
    #define TARGET_OS_IPHONE            1
    #define TARGET_OS_IOS               0
    #define TARGET_OS_WATCH             0
    #define TARGET_OS_TV                1
    #define TARGET_OS_SIMULATOR         1
    #define TARGET_OS_EMBEDDED          0
    #define TARGET_IPHONE_SIMULATOR     TARGET_OS_SIMULATOR / deprecated */
    #define TARGET_OS_NANO              TARGET_OS_WATCH / deprecated */
...