Apple Watch的预处理器宏? [英] Preprocessor macro for Apple Watch?

查看:101
本文介绍了Apple Watch的预处理器宏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看Apple的 Lister(适用于Apple Watch,iOS和OS X)示例。该示例对iOS和OS X进行了测试:

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 <TargetConditionals.h>

#if (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)

@import ListerKit;

#elif TARGET_OS_MAC

@import ListerKitOSX;

#endif

但是,没有测试 TARGET_OS_WATCH 或类似名称。在 TargetConditionals.h 中为手表抓包不会带来任何成功:

However, there is no test for TARGET_OS_WATCH or similar. Grepping for watch in TargetConditionals.h delivers no hits:

$ cat /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
  /SDKs/iPhoneOS7.1.sdk/usr/include/TargetConditionals.h | grep -i watch
$

来自 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 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

问题:苹果手表是否有预处理器?

Question: Is there a preprocessor for Apple's watch?

我正在标记,但是我不确定这是该问题的正确操作系统。

I'm tagging with ios, but I'm not sure that's the correct OS for this question.

下面的列表是从iPhone的 TargetConditionals.h 编译而来的。 Simulator和OS X相似(只是将不同的位设置为1):

The list below was compiled from iPhone's TargetConditionals.h. The Simulator and OS X are similar (they just have different bits set to 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 吗?

Questions: Does the watch use TARGET_OS_EMBEDDED? Does the watch omit TARGET_OS_IPHONE?

推荐答案

从watchOS 2.0开始,您可以在手表上运行本机代码,因此这是一个更相关的问题。

As of watchOS 2.0, you can run native code on the watch, so this is a more relevant question.

我正在使用watchOS 2的第一个早期Beta版,因此情况可能会有所变化,但现在 TARGET_OS_WATCH 在watchOS上设置为1。

I'm using the first early beta of watchOS 2, so this may change, but right now, TARGET_OS_WATCH is set to 1 on watchOS.

(此外,请注意: TARGET_OS_IPHONE 在watchOS上也设置为1,尽管 TARGET_OS_IOS 为0。)

(Also, be careful: TARGET_OS_IPHONE is also set to 1 on watchOS, though TARGET_OS_IOS is 0.)

这篇关于Apple Watch的预处理器宏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆