CocoaPods trunk is moving to be read-only. Read more on the blog, there are 3 months to go.

SimulatorCheck 1.0.0

SimulatorCheck 1.0.0

TestsTested ✗
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Sep 2016
SPMSupports SPM ✗

Maintained by Elvis Nuñez.



SimulatorCheck

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