Latest 1.0.0
Homepage https://github.com/3lvis/SimulatorCheck
License MIT
Platforms ios 8.0, watchos 2.0, tvos 9.0, requires ARC
Authors

Version
License
Platform

Is common to provide special behavior of your app is running on the Simulator, on Objective-C this was pretty simple, this is how you did it:

#if TARGET_IPHONE_SIMULATOR
    // Simulator
#else
    // Device
#endif

In Swift there’s nothing as beautiful as that, so after looking into StackOverflow I found this:

#if (arch(i386) || arch(x86_64)) && os(iOS)
    ...
#endif

Which works, but I hate copy pasting the same code everywhere, also arch(i386)?! That doesn’t say anything, code should be self-explanatory and easy to understand. That’s why I made a simple micro-library that helps with this.

Usage

import SimulatorCheck

if SimulatorCheck.isSimulator {
    // Do something
}

Installation

SimulatorCheck is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'SimulatorCheck'

License

SimulatorCheck is available under the MIT license. See the LICENSE file for more info.

Author

Elvis Nuñez, @3lvis

Latest podspec

{
    "name": "SimulatorCheck",
    "summary": "Check for code running on the Xcode simulator",
    "version": "1.0.0",
    "homepage": "https://github.com/3lvis/SimulatorCheck",
    "license": "MIT",
    "authors": {
        "Elvis Nuu00f1ez": "[email protected]"
    },
    "source": {
        "git": "https://github.com/3lvis/SimulatorCheck.git",
        "tag": "1.0.0"
    },
    "social_media_url": "https://twitter.com/3lvis",
    "platforms": {
        "ios": "8.0",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "requires_arc": true,
    "source_files": "Source"
}

Pin It on Pinterest

Share This