Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ViewController: UIViewController {
super.viewDidLoad()

/*** Display the device version ***/
switch Device.version() {
switch Device.versionOnSimulator() {
/*** iPhone ***/
case .iPhone4: print("It's an iPhone 4")
case .iPhone4S: print("It's an iPhone 4S")
Expand Down
17 changes: 17 additions & 0 deletions Source/iOS/Device.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,23 @@ open class Device {
return getVersion(code: getVersionCode())
}

static public func versionOnSimulator() -> Version {
let version = self.version()
if version == .simulator {
guard let modelIdentifier = ProcessInfo.processInfo.environment["SIMULATOR_MODEL_IDENTIFIER"] else {
return version
}
let simulatorVersion = getVersion(code: modelIdentifier);
if simulatorVersion != .unknown {
return simulatorVersion
}else{
return version
}
}else{
return version
}
}

static public func size() -> Size {
let w: Double = Double(UIScreen.main.bounds.width)
let h: Double = Double(UIScreen.main.bounds.height)
Expand Down