Created
July 30, 2017 09:00
-
-
Save marclove/c1ffa5e93141a1f73b2556482742d7cb to your computer and use it in GitHub Desktop.
iOS Platform Conditional
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Platform { | |
static let isSimulator: Bool = { | |
var isSim = false | |
#if arch(i386) || arch(x86_64) | |
isSim = true | |
#endif | |
return isSim | |
}() | |
} | |
// Usage: | |
if Platform.isSimulator { | |
// Do something on simulator | |
} else { | |
// Do something on real devices | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment