Preprocessor macro for Apple Watch?

前端 未结 4 1930
南旧
南旧 2021-02-19 11:49

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          


        
4条回答
  •  野的像风
    2021-02-19 12:19

    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.

提交回复
热议问题