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 πŸ™…πŸ» πŸ™…πŸ» β˜‘οΈ πŸ™…πŸ» β˜‘οΈ πŸ™…πŸ» β˜‘οΈ

Hopefully someone else finds this useful.


Also published on Medium.