Friday, 27 July 2018

Detect if app is being built for device or simulator in Swift

In Objective-C we can know if an app is being built for device or simulator using macros:

#if TARGET_IPHONE_SIMULATOR
    // Simulator
#else
    // Device
#endif

These are compile time macros and not available at runtime.

How can I achieve the same in Swift? I searched stack overflow, had a look into the docs and cannot figure it out.



from Detect if app is being built for device or simulator in Swift

No comments:

Post a Comment