Although this question has been asked many times in older environments, when I try to run @mbelsky's answer on a device running iOS 11.2, the simulator block of the code below runs, rather than the device block. When I run the code on the simulator, the simulator runs as expected.
@IBOutlet weak var testSimulatorFlag: UILabel! {
didSet {
#if IOS_SIMULATOR
testSimulatorFlag.text = "Compiler thinks this is a simulator"
#else
testSimulatorFlag.text = "Compiler thinks this is a device"
#endif
}
}
This is a screenshot of how the project's Swift-Compiler, Custom Flags is set:
Here is a sample project that demonstrates the issue. Thanks in advance for any suggestions.