Skip to content

Commit

Permalink
[Swift 3.0] Fix crash for looking up sim id on real device (#62)
Browse files Browse the repository at this point in the history
* Fix crash for looking up sim id on real device

* Use better API to get env var that won't crash

* change unknown to os name

* Fix line length and lowercase the sim enum

* Remove NS prefix for Swift 3
  • Loading branch information
kdawgwilk authored and dennisweissmann committed Jan 5, 2017
1 parent 6cf55b9 commit 6f55a6e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Source/Device.swift
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,17 @@ public enum Device {
case "iPad5,1", "iPad5,2": return iPadMini4
case "iPad6,3", "iPad6,4": return iPadPro9Inch
case "iPad6,7", "iPad6,8": return iPadPro12Inch
// swiftlint:disable:next force_unwrapping
case "i386", "x86_64": return simulator(mapToDevice(identifier: String(validatingUTF8: getenv("SIMULATOR_MODEL_IDENTIFIER"))!))
case "i386", "x86_64": return simulator(mapToDevice(
identifier: ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] ?? "iOS"
))
default: return unknown(identifier)
}
#elseif os(tvOS)
switch identifier {
case "AppleTV5,3": return appleTV4
// swiftlint:disable:next force_unwrapping
case "i386", "x86_64": return simulator(mapToDevice(identifier: String(validatingUTF8: getenv("SIMULATOR_MODEL_IDENTIFIER"))!))
case "i386", "x86_64": return simulator(mapToDevice(
identifier: ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] ?? "tvOS"
))
default: return unknown(identifier)
}
#endif
Expand Down

0 comments on commit 6f55a6e

Please sign in to comment.