TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Sep 2016 |
SPMSupports SPM | ✗ |
Maintained by Elvis Nuñez.
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.
import SimulatorCheck
if SimulatorCheck.isSimulator {
// Do something
}
SimulatorCheck is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'SimulatorCheck'
SimulatorCheck is available under the MIT license. See the LICENSE file for more info.
Elvis Nuñez, @3lvis