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` | 🙅🏻 | 🙅🏻 | ☑️ | 🙅🏻 | ☑️ | 🙅🏻 | ☑️ |