A Sane Reference for TargetConditionals
Iβve spent the past couple days cleaning up some code to work on iOS, macOS, and watchOS. One thing I constantly struggle with is keeping the values I need from TargetConditionals.h in my head for when I want to #if branch a segment of Objective-C code for a specific platform.
So . . . I made a table.
Current as of: iOS 9.3, tvOS 9.2, watchOS 2.2, macOS 10.11
| Macro | π» device | π± device | π± simulator | βοΈ device | βοΈ simulator | πΊ device | πΊ simulator |
|---|---|---|---|---|---|---|---|
| `TARGET_OS_MAC` | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ |
| `TARGET_OS_IPHONE` | π π» | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ |
| `TARGET_OS_IOS` | π π» | βοΈ | βοΈ | π π» | π π» | π π» | π π» |
| `TARGET_OS_WATCH` | π π» | π π» | π π» | βοΈ | βοΈ | π π» | π π» |
| `TARGET_OS_TV` | π π» | π π» | π π» | π π» | π π» | βοΈ | βοΈ |
| `TARGET_OS_SIMULATOR` | π π» | π π» | βοΈ | π π» | βοΈ | π π» | βοΈ |
| `TARGET_OS_EMBEDDED` | π π» | βοΈ | π π» | βοΈ | π π» | βοΈ | π π» |
| `TARGET_IPHONE_SIMULATOR` | π π» | π π» | βοΈ | π π» | βοΈ | π π» | βοΈ |