Created
April 19, 2017 18:54
-
-
Save ahcode0919/3402cedbf78fdfa3f3d28816dd00dfb4 to your computer and use it in GitHub Desktop.
Check if Application is running on a simulator or physical iOS device
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 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