Skip to content

Instantly share code, notes, and snippets.

@marclove
Created July 30, 2017 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marclove/c1ffa5e93141a1f73b2556482742d7cb to your computer and use it in GitHub Desktop.
Save marclove/c1ffa5e93141a1f73b2556482742d7cb to your computer and use it in GitHub Desktop.
iOS Platform Conditional
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