Skip to content

Instantly share code, notes, and snippets.

@ahcode0919
Created April 19, 2017 18:54
Show Gist options
  • Save ahcode0919/3402cedbf78fdfa3f3d28816dd00dfb4 to your computer and use it in GitHub Desktop.
Save ahcode0919/3402cedbf78fdfa3f3d28816dd00dfb4 to your computer and use it in GitHub Desktop.
Check if Application is running on a simulator or physical iOS device
struct Device {
/// Detects if the current architecture is a Simulator
static let isSimulator: Bool = {
var isSim = false
#if arch(i386) || arch(x86_64)
isSim = true
#endif
return isSim
}()
}
/*
Usage:
if Device.isSimulator {
print("Running on a simulator")
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment