mirror of
https://github.com/devicekit/DeviceKit.git
synced 2026-06-16 10:24:30 +00:00
new device identifiers for iPhone 8, Plus and X
support for Apple TV 4K support for HomePod iOS devices have two new properties: allPlusSizedDevices and allProDevices
This commit is contained in:
committed by
Dennis Weissmann
parent
9abf07cf75
commit
7ee50ddae0
@@ -168,11 +168,19 @@ public enum Device {
|
||||
///
|
||||
/// 
|
||||
case iPadPro10Inch
|
||||
/// Device is a [HomePod](https://www.apple.com/homepod/)
|
||||
///
|
||||
/// 
|
||||
case HomePod
|
||||
#elseif os(tvOS)
|
||||
/// Device is an [Apple TV](http://www.apple.com/tv/)
|
||||
/// Device is an [Apple TV 4](https://support.apple.com/kb/SP724)
|
||||
///
|
||||
/// 
|
||||
case appleTV4
|
||||
/// Device is an [Apple TV 4K](https://support.apple.com/kb/SP769)
|
||||
///
|
||||
/// 
|
||||
case appleTV4K
|
||||
#endif
|
||||
|
||||
/// Device is [Simulator](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/iOS_Simulator_Guide/Introduction/Introduction.html)
|
||||
@@ -225,9 +233,9 @@ public enum Device {
|
||||
case "iPhone9,1", "iPhone9,3": return iPhone7
|
||||
case "iPhone9,2", "iPhone9,4": return iPhone7Plus
|
||||
case "iPhone8,4": return iPhoneSE
|
||||
case "iPhone10,4": return iPhone8
|
||||
case "iPhone10,5": return iPhone8Plus
|
||||
case "iPhone10,3": return iPhoneX
|
||||
case "iPhone10,1", "iPhone10,4": return iPhone8
|
||||
case "iPhone10,2", "iPhone10,5": return iPhone8Plus
|
||||
case "iPhone10,3", "iPhone10,6": return iPhoneX
|
||||
case "iPad2,1", "iPad2,2", "iPad2,3", "iPad2,4": return iPad2
|
||||
case "iPad3,1", "iPad3,2", "iPad3,3": return iPad3
|
||||
case "iPad3,4", "iPad3,5", "iPad3,6": return iPad4
|
||||
@@ -242,12 +250,14 @@ public enum Device {
|
||||
case "iPad6,7", "iPad6,8": return iPadPro12Inch
|
||||
case "iPad7,1", "iPad7,2": return iPadPro12Inch2
|
||||
case "iPad7,3", "iPad7,4": return iPadPro10Inch
|
||||
case "AudioAccessory1,1": return HomePod
|
||||
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
|
||||
case "AppleTV6,2": return appleTV4K
|
||||
case "i386", "x86_64": return simulator(mapToDevice(identifier: ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] ?? "tvOS"))
|
||||
default: return unknown(identifier)
|
||||
}
|
||||
@@ -270,6 +280,16 @@ public enum Device {
|
||||
return [.iPad2, .iPad3, .iPad4, .iPadAir, .iPadAir2, .iPad5, .iPadMini, .iPadMini2, .iPadMini3, .iPadMini4, .iPadPro9Inch, .iPadPro12Inch, .iPadPro12Inch2, .iPadPro10Inch]
|
||||
}
|
||||
|
||||
/// All Plus-Sized Devices
|
||||
public static var allPlusSizedDevices: [Device] {
|
||||
return [.iPhone6Plus, .iPhone6sPlus, .iPhone7Plus, .iPhone8Plus]
|
||||
}
|
||||
|
||||
/// All Plus-Sized Devices
|
||||
public static var allProDevices: [Device] {
|
||||
return [.iPadPro9Inch, .iPadPro12Inch, .iPadPro12Inch2, .iPadPro10Inch]
|
||||
}
|
||||
|
||||
/// All simulator iPods
|
||||
public static var allSimulatorPods: [Device] {
|
||||
return allPods.map(Device.simulator)
|
||||
@@ -349,6 +369,7 @@ public enum Device {
|
||||
case .iPadPro12Inch: return 12.9
|
||||
case .iPadPro12Inch2: return 12.9
|
||||
case .iPadPro10Inch: return 10.5
|
||||
case .HomePod: return -1
|
||||
case .simulator(let model): return model.diagonal
|
||||
case .unknown: return -1
|
||||
}
|
||||
@@ -388,6 +409,7 @@ public enum Device {
|
||||
case .iPadPro12Inch: return (width: 3, height: 4)
|
||||
case .iPadPro12Inch2: return (width: 3, height: 4)
|
||||
case .iPadPro10Inch: return (width: 3, height: 4)
|
||||
case .HomePod: return (width: 4, height: 5)
|
||||
case .simulator(let model): return model.screenRatio
|
||||
case .unknown: return (width: -1, height: -1)
|
||||
}
|
||||
@@ -395,7 +417,7 @@ public enum Device {
|
||||
#elseif os(tvOS)
|
||||
/// All TVs
|
||||
public static var allTVs: [Device] {
|
||||
return [.appleTV4]
|
||||
return [.appleTV4, .appleTV4K]
|
||||
}
|
||||
|
||||
/// All simulator TVs
|
||||
@@ -511,6 +533,7 @@ public enum Device {
|
||||
case .iPadPro12Inch: return 264
|
||||
case .iPadPro12Inch2: return 264
|
||||
case .iPadPro10Inch: return 264
|
||||
case .HomePod: return -1
|
||||
case .simulator(let model): return model.ppi
|
||||
case .unknown: return nil
|
||||
}
|
||||
@@ -558,12 +581,14 @@ extension Device: CustomStringConvertible {
|
||||
case .iPadPro12Inch: return "iPad Pro (12.9-inch)"
|
||||
case .iPadPro12Inch2: return "iPad Pro (12.9-inch) 2"
|
||||
case .iPadPro10Inch: return "iPad Pro (10.5-inch)"
|
||||
case .HomePod: return "HomePod"
|
||||
case .simulator(let model): return "Simulator (\(model))"
|
||||
case .unknown(let identifier): return identifier
|
||||
}
|
||||
#elseif os(tvOS)
|
||||
switch self {
|
||||
case .appleTV4: return "Apple TV 4"
|
||||
case .appleTV4K: return "Apple TV 4K"
|
||||
case .simulator(let model): return "Simulator (\(model))"
|
||||
case .unknown(let identifier): return identifier
|
||||
}
|
||||
|
||||
+50
-34
@@ -12,7 +12,7 @@
|
||||
%{
|
||||
class Device:
|
||||
|
||||
def __init__(self, caseName, comment, imageURL, identifiers, diagonal, screenRatio, description, ppi):
|
||||
def __init__(self, caseName, comment, imageURL, identifiers, diagonal, screenRatio, description, ppi, isPlusFormFactor, isPro):
|
||||
self.caseName = caseName
|
||||
self.comment = comment
|
||||
self.imageURL = imageURL
|
||||
@@ -21,54 +21,60 @@ class Device:
|
||||
self.screenRatio = screenRatio
|
||||
self.description = description
|
||||
self.ppi = ppi
|
||||
self.isPlusFormFactor = isPlusFormFactor
|
||||
self.isPro = isPro
|
||||
|
||||
# iOS
|
||||
iPods = [
|
||||
Device("iPodTouch5", "Device is an [iPod Touch (5th generation)](https://support.apple.com/kb/SP657)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP657/sp657_ipod-touch_size.jpg", ["iPod5,1"], 4, (9, 16), "iPod Touch 5", 326),
|
||||
Device("iPodTouch6", "Device is an [iPod Touch (6th generation)](https://support.apple.com/kb/SP720)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP720/SP720-ipod-touch-specs-color-sg-2015.jpg", ["iPod7,1"], 4, (9, 16), "iPod Touch 6", 326)
|
||||
Device("iPodTouch5", "Device is an [iPod Touch (5th generation)](https://support.apple.com/kb/SP657)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP657/sp657_ipod-touch_size.jpg", ["iPod5,1"], 4, (9, 16), "iPod Touch 5", 326, False, False),
|
||||
Device("iPodTouch6", "Device is an [iPod Touch (6th generation)](https://support.apple.com/kb/SP720)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP720/SP720-ipod-touch-specs-color-sg-2015.jpg", ["iPod7,1"], 4, (9, 16), "iPod Touch 6", 326, False, False)
|
||||
]
|
||||
|
||||
iPhones = [
|
||||
Device("iPhone4", "Device is an [iPhone 4](https://support.apple.com/kb/SP587)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP643/sp643_iphone4s_color_black.jpg", ["iPhone3,1", "iPhone3,2", "iPhone3,3"], 3.5, (2, 3), "iPhone 4", 326),
|
||||
Device("iPhone4s", "Device is an [iPhone 4s](https://support.apple.com/kb/SP643)", "https://support.apple.com/library/content/dam/edam/applecare/images/en_US/iphone/iphone5s/iphone_4s.png", ["iPhone4,1"], 3.5, (2, 3), "iPhone 4s", 326),
|
||||
Device("iPhone5", "Device is an [iPhone 5](https://support.apple.com/kb/SP655)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP655/sp655_iphone5_color.jpg", ["iPhone5,1", "iPhone5,2"], 4, (9, 16), "iPhone 5", 326),
|
||||
Device("iPhone5c", "Device is an [iPhone 5c](https://support.apple.com/kb/SP684)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP684/SP684-color_yellow.jpg", ["iPhone5,3", "iPhone5,4"], 4, (9, 16), "iPhone 5c", 326),
|
||||
Device("iPhone5s", "Device is an [iPhone 5s](https://support.apple.com/kb/SP685)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP685/SP685-color_black.jpg", ["iPhone6,1", "iPhone6,2"], 4, (9, 16), "iPhone 5s", 326),
|
||||
Device("iPhone6", "Device is an [iPhone 6](https://support.apple.com/kb/SP705)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP705/SP705-iphone_6-mul.png", ["iPhone7,2"], 4.7, (9, 16), "iPhone 6", 326),
|
||||
Device("iPhone6Plus", "Device is an [iPhone 6 Plus](https://support.apple.com/kb/SP706)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP706/SP706-iphone_6_plus-mul.png", ["iPhone7,1"], 5.5, (9, 16), "iPhone 6 Plus", 401),
|
||||
Device("iPhone6s", "Device is an [iPhone 6s](https://support.apple.com/kb/SP726)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP726/SP726-iphone6s-gray-select-2015.png", ["iPhone8,1"], 4.7, (9, 16), "iPhone 6s", 326),
|
||||
Device("iPhone6sPlus", "Device is an [iPhone 6s Plus](https://support.apple.com/kb/SP727)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP727/SP727-iphone6s-plus-gray-select-2015.png", ["iPhone8,2"], 5.5, (9, 16), "iPhone 6s Plus", 401),
|
||||
Device("iPhone7", "Device is an [iPhone 7](https://support.apple.com/kb/SP743)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP743/iphone7-black.png", ["iPhone9,1", "iPhone9,3"], 4.7, (9, 16), "iPhone 7", 326),
|
||||
Device("iPhone7Plus", "Device is an [iPhone 7 Plus](https://support.apple.com/kb/SP744)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP744/iphone7-plus-black.png", ["iPhone9,2", "iPhone9,4"], 5.5, (9, 16), "iPhone 7 Plus", 401),
|
||||
Device("iPhoneSE", "Device is an [iPhone SE](https://support.apple.com/kb/SP738)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP738/SP738.png", ["iPhone8,4"], 4, (9, 16), "iPhone SE", 326),
|
||||
Device("iPhone8", "Device is an [iPhone 8](https://support.apple.com/kb/SP767)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP767/iphone8.png", ["iPhone10,4"], 4.7, (9, 16), "iPhone 8", 326),
|
||||
Device("iPhone8Plus", "Device is an [iPhone 8 Plus](https://support.apple.com/kb/SP768)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP768/iphone8plus.png", ["iPhone10,5"], 5.5, (9, 16), "iPhone 8 Plus", 401),
|
||||
Device("iPhoneX", "Device is an [iPhone X](https://support.apple.com/kb/SP770)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP770/iphonex.png", ["iPhone10,3"], 5.8, (9, 19.5), "iPhone X", 458)
|
||||
Device("iPhone4", "Device is an [iPhone 4](https://support.apple.com/kb/SP587)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP643/sp643_iphone4s_color_black.jpg", ["iPhone3,1", "iPhone3,2", "iPhone3,3"], 3.5, (2, 3), "iPhone 4", 326, False, False),
|
||||
Device("iPhone4s", "Device is an [iPhone 4s](https://support.apple.com/kb/SP643)", "https://support.apple.com/library/content/dam/edam/applecare/images/en_US/iphone/iphone5s/iphone_4s.png", ["iPhone4,1"], 3.5, (2, 3), "iPhone 4s", 326, False, False),
|
||||
Device("iPhone5", "Device is an [iPhone 5](https://support.apple.com/kb/SP655)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP655/sp655_iphone5_color.jpg", ["iPhone5,1", "iPhone5,2"], 4, (9, 16), "iPhone 5", 326, False, False),
|
||||
Device("iPhone5c", "Device is an [iPhone 5c](https://support.apple.com/kb/SP684)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP684/SP684-color_yellow.jpg", ["iPhone5,3", "iPhone5,4"], 4, (9, 16), "iPhone 5c", 326, False, False),
|
||||
Device("iPhone5s", "Device is an [iPhone 5s](https://support.apple.com/kb/SP685)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP685/SP685-color_black.jpg", ["iPhone6,1", "iPhone6,2"], 4, (9, 16), "iPhone 5s", 326, False, False),
|
||||
Device("iPhone6", "Device is an [iPhone 6](https://support.apple.com/kb/SP705)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP705/SP705-iphone_6-mul.png", ["iPhone7,2"], 4.7, (9, 16), "iPhone 6", 326, False, False),
|
||||
Device("iPhone6Plus", "Device is an [iPhone 6 Plus](https://support.apple.com/kb/SP706)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP706/SP706-iphone_6_plus-mul.png", ["iPhone7,1"], 5.5, (9, 16), "iPhone 6 Plus", 401, True, False),
|
||||
Device("iPhone6s", "Device is an [iPhone 6s](https://support.apple.com/kb/SP726)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP726/SP726-iphone6s-gray-select-2015.png", ["iPhone8,1"], 4.7, (9, 16), "iPhone 6s", 326, False, False),
|
||||
Device("iPhone6sPlus", "Device is an [iPhone 6s Plus](https://support.apple.com/kb/SP727)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP727/SP727-iphone6s-plus-gray-select-2015.png", ["iPhone8,2"], 5.5, (9, 16), "iPhone 6s Plus", 401, True, False),
|
||||
Device("iPhone7", "Device is an [iPhone 7](https://support.apple.com/kb/SP743)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP743/iphone7-black.png", ["iPhone9,1", "iPhone9,3"], 4.7, (9, 16), "iPhone 7", 326, False, False),
|
||||
Device("iPhone7Plus", "Device is an [iPhone 7 Plus](https://support.apple.com/kb/SP744)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP744/iphone7-plus-black.png", ["iPhone9,2", "iPhone9,4"], 5.5, (9, 16), "iPhone 7 Plus", 401, True, False),
|
||||
Device("iPhoneSE", "Device is an [iPhone SE](https://support.apple.com/kb/SP738)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP738/SP738.png", ["iPhone8,4"], 4, (9, 16), "iPhone SE", 326, False, False),
|
||||
Device("iPhone8", "Device is an [iPhone 8](https://support.apple.com/kb/SP767)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP767/iphone8.png", ["iPhone10,1", "iPhone10,4"], 4.7, (9, 16), "iPhone 8", 326, False, False),
|
||||
Device("iPhone8Plus", "Device is an [iPhone 8 Plus](https://support.apple.com/kb/SP768)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP768/iphone8plus.png", ["iPhone10,2", "iPhone10,5"], 5.5, (9, 16), "iPhone 8 Plus", 401, True, False),
|
||||
Device("iPhoneX", "Device is an [iPhone X](https://support.apple.com/kb/SP770)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP770/iphonex.png", ["iPhone10,3", "iPhone10,6"], 5.8, (9, 19.5), "iPhone X", 458, False, False)
|
||||
]
|
||||
|
||||
iPads = [
|
||||
Device("iPad2", "Device is an [iPad 2](https://support.apple.com/kb/SP622)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP622/SP622_01-ipad2-mul.png", ["iPad2,1", "iPad2,2", "iPad2,3", "iPad2,4"], 9.7, (3, 4), "iPad 2", 132),
|
||||
Device("iPad3", "Device is an [iPad (3rd generation)](https://support.apple.com/kb/SP647)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP662/sp662_ipad-4th-gen_color.jpg", ["iPad3,1", "iPad3,2", "iPad3,3"], 9.7, (3, 4), "iPad 3", 264),
|
||||
Device("iPad4", "Device is an [iPad (4th generation)](https://support.apple.com/kb/SP662)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP662/sp662_ipad-4th-gen_color.jpg", ["iPad3,4", "iPad3,5", "iPad3,6"], 9.7, (3, 4), "iPad 4", 264),
|
||||
Device("iPadAir", "Device is an [iPad Air](https://support.apple.com/kb/SP692)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP692/SP692-specs_color-mul.png", ["iPad4,1", "iPad4,2", "iPad4,3"], 9.7, (3, 4), "iPad Air", 264),
|
||||
Device("iPadAir2", "Device is an [iPad Air 2](https://support.apple.com/kb/SP708)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP708/SP708-space_gray.jpeg", ["iPad5,3", "iPad5,4"], 9.7, (3, 4), "iPad Air 2", 264),
|
||||
Device("iPad5", "Device is an [iPad 5](https://support.apple.com/kb/SP751)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP751/ipad_5th_generation.png", ["iPad6,11", "iPad6,12"], 9.7, (3, 4), "iPad 5", 264),
|
||||
Device("iPadMini", "Device is an [iPad Mini](https://support.apple.com/kb/SP661)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP661/sp661_ipad_mini_color.jpg", ["iPad2,5", "iPad2,6", "iPad2,7"], 7.9, (3, 4), "iPad Mini", 163),
|
||||
Device("iPadMini2", "Device is an [iPad Mini 2](https://support.apple.com/kb/SP693)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP693/SP693-specs_color-mul.png", ["iPad4,4", "iPad4,5", "iPad4,6"], 7.9, (3, 4), "iPad Mini 2", 326),
|
||||
Device("iPadMini3", "Device is an [iPad Mini 3](https://support.apple.com/kb/SP709)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP709/SP709-space_gray.jpeg", ["iPad4,7", "iPad4,8", "iPad4,9"], 7.9, (3, 4), "iPad Mini 3", 326),
|
||||
Device("iPadMini4", "Device is an [iPad Mini 4](https://support.apple.com/kb/SP725)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP725/SP725ipad-mini-4.png", ["iPad5,1", "iPad5,2"], 7.9, (3, 4), "iPad Mini 4", 326),
|
||||
Device("iPadPro9Inch", "Device is an [iPad Pro](https://support.apple.com/kb/SP739)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP739/SP739.png", ["iPad6,3", "iPad6,4"], 9.7, (3, 4), "iPad Pro (9.7-inch)", 264),
|
||||
Device("iPadPro12Inch", "Device is an [iPad Pro](https://support.apple.com/kb/sp723)", "http://images.apple.com/v/ipad-pro/c/images/shared/buystrip/ipad_pro_large_2x.png", ["iPad6,7", "iPad6,8"], 12.9, (3, 4), "iPad Pro (12.9-inch)", 264),
|
||||
Device("iPadPro12Inch2", "Device is an [iPad Pro](https://support.apple.com/kb/SP761)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP761/ipad-pro-12in-hero-201706.png", ["iPad7,1", "iPad7,2"], 12.9, (3, 4), "iPad Pro (12.9-inch) 2", 264),
|
||||
Device("iPadPro10Inch", "Device is an [iPad Pro 10.5](https://support.apple.com/kb/SP762)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP761/ipad-pro-10in-hero-201706.png", ["iPad7,3", "iPad7,4"], 10.5, (3, 4), "iPad Pro (10.5-inch)", 264)
|
||||
Device("iPad2", "Device is an [iPad 2](https://support.apple.com/kb/SP622)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP622/SP622_01-ipad2-mul.png", ["iPad2,1", "iPad2,2", "iPad2,3", "iPad2,4"], 9.7, (3, 4), "iPad 2", 132, False, False),
|
||||
Device("iPad3", "Device is an [iPad (3rd generation)](https://support.apple.com/kb/SP647)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP662/sp662_ipad-4th-gen_color.jpg", ["iPad3,1", "iPad3,2", "iPad3,3"], 9.7, (3, 4), "iPad 3", 264, False, False),
|
||||
Device("iPad4", "Device is an [iPad (4th generation)](https://support.apple.com/kb/SP662)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP662/sp662_ipad-4th-gen_color.jpg", ["iPad3,4", "iPad3,5", "iPad3,6"], 9.7, (3, 4), "iPad 4", 264, False, False),
|
||||
Device("iPadAir", "Device is an [iPad Air](https://support.apple.com/kb/SP692)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP692/SP692-specs_color-mul.png", ["iPad4,1", "iPad4,2", "iPad4,3"], 9.7, (3, 4), "iPad Air", 264, False, False),
|
||||
Device("iPadAir2", "Device is an [iPad Air 2](https://support.apple.com/kb/SP708)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP708/SP708-space_gray.jpeg", ["iPad5,3", "iPad5,4"], 9.7, (3, 4), "iPad Air 2", 264, False, False),
|
||||
Device("iPad5", "Device is an [iPad 5](https://support.apple.com/kb/SP751)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP751/ipad_5th_generation.png", ["iPad6,11", "iPad6,12"], 9.7, (3, 4), "iPad 5", 264, False, False),
|
||||
Device("iPadMini", "Device is an [iPad Mini](https://support.apple.com/kb/SP661)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP661/sp661_ipad_mini_color.jpg", ["iPad2,5", "iPad2,6", "iPad2,7"], 7.9, (3, 4), "iPad Mini", 163, False, False),
|
||||
Device("iPadMini2", "Device is an [iPad Mini 2](https://support.apple.com/kb/SP693)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP693/SP693-specs_color-mul.png", ["iPad4,4", "iPad4,5", "iPad4,6"], 7.9, (3, 4), "iPad Mini 2", 326, False, False),
|
||||
Device("iPadMini3", "Device is an [iPad Mini 3](https://support.apple.com/kb/SP709)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP709/SP709-space_gray.jpeg", ["iPad4,7", "iPad4,8", "iPad4,9"], 7.9, (3, 4), "iPad Mini 3", 326, False, False),
|
||||
Device("iPadMini4", "Device is an [iPad Mini 4](https://support.apple.com/kb/SP725)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP725/SP725ipad-mini-4.png", ["iPad5,1", "iPad5,2"], 7.9, (3, 4), "iPad Mini 4", 326, False, False),
|
||||
Device("iPadPro9Inch", "Device is an [iPad Pro](https://support.apple.com/kb/SP739)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP739/SP739.png", ["iPad6,3", "iPad6,4"], 9.7, (3, 4), "iPad Pro (9.7-inch)", 264, False, True),
|
||||
Device("iPadPro12Inch", "Device is an [iPad Pro](https://support.apple.com/kb/sp723)", "http://images.apple.com/v/ipad-pro/c/images/shared/buystrip/ipad_pro_large_2x.png", ["iPad6,7", "iPad6,8"], 12.9, (3, 4), "iPad Pro (12.9-inch)", 264, False, True),
|
||||
Device("iPadPro12Inch2", "Device is an [iPad Pro](https://support.apple.com/kb/SP761)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP761/ipad-pro-12in-hero-201706.png", ["iPad7,1", "iPad7,2"], 12.9, (3, 4), "iPad Pro (12.9-inch) 2", 264, False, True),
|
||||
Device("iPadPro10Inch", "Device is an [iPad Pro 10.5](https://support.apple.com/kb/SP762)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP761/ipad-pro-10in-hero-201706.png", ["iPad7,3", "iPad7,4"], 10.5, (3, 4), "iPad Pro (10.5-inch)", 264, False, True)
|
||||
]
|
||||
|
||||
homePods = [
|
||||
Device("HomePod", "Device is a [HomePod](https://www.apple.com/homepod/)", "https://images.apple.com/v/homepod/d/images/overview/homepod_side_dark_large_2x.jpg", ["AudioAccessory1,1"], -1, (4, 5), "HomePod", -1, False, False),
|
||||
]
|
||||
# tvOS
|
||||
tvs = [
|
||||
Device("appleTV4", "Device is an [Apple TV](http://www.apple.com/tv/)", "http://images.apple.com/v/tv/c/images/overview/buy_tv_large_2x.jpg", ["AppleTV5,3"], 0, (), "Apple TV 4", -1)
|
||||
Device("appleTV4", "Device is an [Apple TV 4](https://support.apple.com/kb/SP724)", "http://images.apple.com/v/tv/c/images/overview/buy_tv_large_2x.jpg", ["AppleTV5,3"], 0, (), "Apple TV 4", -1, False, False),
|
||||
Device("appleTV4K", "Device is an [Apple TV 4K](https://support.apple.com/kb/SP769)", "https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/SP769/appletv4k.png", ["AppleTV6,2"], 0, (), "Apple TV 4K", -1, False, False)
|
||||
]
|
||||
|
||||
iOSDevices = iPods + iPhones + iPads
|
||||
iOSDevices = iPods + iPhones + iPads + homePods
|
||||
tvOSDevices = tvs
|
||||
}%
|
||||
import UIKit
|
||||
@@ -190,6 +196,16 @@ public enum Device {
|
||||
return [${', '.join(list(map(lambda device: "." + device.caseName, iPads)))}]
|
||||
}
|
||||
|
||||
/// All Plus-Sized Devices
|
||||
public static var allPlusSizedDevices: [Device] {
|
||||
return [${', '.join(list(map(lambda device: "." + device.caseName, list(filter(lambda device: device.isPlusFormFactor == True, iOSDevices)))))}]
|
||||
}
|
||||
|
||||
/// All Plus-Sized Devices
|
||||
public static var allProDevices: [Device] {
|
||||
return [${', '.join(list(map(lambda device: "." + device.caseName, list(filter(lambda device: device.isPro == True, iOSDevices)))))}]
|
||||
}
|
||||
|
||||
/// All simulator iPods
|
||||
public static var allSimulatorPods: [Device] {
|
||||
return allPods.map(Device.simulator)
|
||||
|
||||
+15
-1
@@ -64,9 +64,12 @@ class DeviceKitTests: XCTestCase {
|
||||
XCTAssertEqual(Device.mapToDevice(identifier: "iPhone9,2"), .iPhone7Plus)
|
||||
XCTAssertEqual(Device.mapToDevice(identifier: "iPhone9,4"), .iPhone7Plus)
|
||||
XCTAssertEqual(Device.mapToDevice(identifier: "iPhone8,4"), .iPhoneSE)
|
||||
XCTAssertEqual(Device.mapToDevice(identifier: "iPhone10,1"), .iPhone8)
|
||||
XCTAssertEqual(Device.mapToDevice(identifier: "iPhone10,4"), .iPhone8)
|
||||
XCTAssertEqual(Device.mapToDevice(identifier: "iPhone10,2"), .iPhone8Plus)
|
||||
XCTAssertEqual(Device.mapToDevice(identifier: "iPhone10,5"), .iPhone8Plus)
|
||||
XCTAssertEqual(Device.mapToDevice(identifier: "iPhone10,3"), .iPhoneX)
|
||||
XCTAssertEqual(Device.mapToDevice(identifier: "iPhone10,6"), .iPhoneX)
|
||||
XCTAssertEqual(Device.mapToDevice(identifier: "iPad2,1"), .iPad2)
|
||||
XCTAssertEqual(Device.mapToDevice(identifier: "iPad2,2"), .iPad2)
|
||||
XCTAssertEqual(Device.mapToDevice(identifier: "iPad2,3"), .iPad2)
|
||||
@@ -354,6 +357,14 @@ class DeviceKitTests: XCTestCase {
|
||||
XCTAssertEqual(Device.simulator(.iPadPro10Inch).ppi, 264)
|
||||
}
|
||||
|
||||
func testIsPlusSized() {
|
||||
XCTAssertEqual(Device.allPlusSizedDevices, [.iPhone6Plus, .iPhone6sPlus, .iPhone7Plus, .iPhone8Plus])
|
||||
}
|
||||
|
||||
func testIsPro() {
|
||||
XCTAssertEqual(Device.allProDevices, [.iPadPro9Inch, .iPadPro12Inch, .iPadPro12Inch2, .iPadPro10Inch])
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// MARK: - tvOS
|
||||
@@ -363,7 +374,8 @@ class DeviceKitTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testDescriptionFromIdentifier() {
|
||||
XCTAssertEqual(Device.mapToDevice(identifier: "AppleTV5,3").description, "Apple TV 4")
|
||||
XCTAssertEqual(Device.mapToDevice(identifier: "AppleTV5,3").description, "Apple TV 4")
|
||||
XCTAssertEqual(Device.mapToDevice(identifier: "AppleTV6,2").description, "Apple TV 4K")
|
||||
}
|
||||
|
||||
/// Test that all the ppi values for applicable devices match the public information available at wikipedia. Test non-applicable devices return nil.
|
||||
@@ -371,8 +383,10 @@ class DeviceKitTests: XCTestCase {
|
||||
// Non-applicable devices:
|
||||
// Apple TV
|
||||
XCTAssertEqual(Device.appleTV4.ppi, nil)
|
||||
XCTAssertEqual(Device.appleTV4K.ppi, nil)
|
||||
// Simulators
|
||||
XCTAssertEqual(Device.simulator(Device.appleTV4).ppi, nil)
|
||||
XCTAssertEqual(Device.simulator(Device.appleTV4K).ppi, nil)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user