Skip to content

Instantly share code, notes, and snippets.

@cmittendorf
Created June 24, 2016 08:32
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 cmittendorf/106a5f8bad2814dff3c9a7d15b5653b7 to your computer and use it in GitHub Desktop.
Save cmittendorf/106a5f8bad2814dff3c9a7d15b5653b7 to your computer and use it in GitHub Desktop.
Test in your iOS app, if your app is running in the Simulator.
import Foundation
struct Platform {
/// Check if the current platform is the simulator.
///
/// - Returns: true if the current platform is the simulator
static let isSimulator: Bool = {
var isSim = false
#if arch(i386) || arch(x86_64)
isSim = true
#endif
return isSim
}()
}
print("\(Platform.isSimulator)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment