8
8
import Foundation
9
9
10
10
// https://github.com/schickling/Device.swift/blob/master/Device/UIDeviceExtension.swift
11
+ // https://ipsw.me/otas
11
12
// MARK: -
12
13
internal extension UIDevice {
13
14
@@ -21,21 +22,24 @@ internal extension UIDevice {
21
22
return deviceType == . iPhone6S || deviceType == . iPhone6SPlus ||
22
23
deviceType == . iPhone7 || deviceType == . iPhone7Plus ||
23
24
deviceType == . iPhone8 || deviceType == . iPhone8Plus ||
24
- deviceType == . iPhoneX
25
+ deviceType == . iPhoneX || deviceType == . iPhoneXR ||
26
+ deviceType == . iPhoneXS || deviceType == . iPhoneXSMax
27
+
25
28
}
26
29
}
27
30
28
31
internal var hasHapticFeedback : Bool {
29
32
get {
30
33
return deviceType == . iPhone7 || deviceType == . iPhone7Plus ||
31
- deviceType == . iPhone8 || deviceType == . iPhone8Plus ||
32
- deviceType == . iPhoneX
34
+ deviceType == . iPhone8 || deviceType == . iPhone8Plus ||
35
+ deviceType == . iPhoneX || deviceType == . iPhoneXR ||
36
+ deviceType == . iPhoneXS || deviceType == . iPhoneXSMax
33
37
}
34
38
}
35
39
}
36
40
37
41
/// Enum representing the different types of iOS devices available
38
- internal enum DeviceType : String , EnumProtocol {
42
+ internal enum DeviceType : String {
39
43
case iPhone2G
40
44
41
45
case iPhone3G
@@ -63,6 +67,9 @@ internal enum DeviceType: String, EnumProtocol {
63
67
case iPhone8Plus
64
68
65
69
case iPhoneX
70
+ case iPhoneXS
71
+ case iPhoneXSMax
72
+ case iPhoneXR
66
73
67
74
case iPodTouch1G
68
75
case iPodTouch2G
@@ -113,7 +120,6 @@ internal enum DeviceType: String, EnumProtocol {
113
120
// MARK: Variables
114
121
/// Returns the display name of the device type
115
122
internal var displayName : String {
116
-
117
123
switch self {
118
124
case . iPhone2G: return " iPhone 2G "
119
125
case . iPhone3G: return " iPhone 3G "
@@ -133,6 +139,9 @@ internal enum DeviceType: String, EnumProtocol {
133
139
case . iPhone8: return " iPhone 8 "
134
140
case . iPhone8Plus: return " iPhone 8 Plus "
135
141
case . iPhoneX: return " iPhone X "
142
+ case . iPhoneXS: return " iPHone XS "
143
+ case . iPhoneXSMax: return " iPhone XS Max "
144
+ case . iPhoneXR: return " iPhone XR "
136
145
case . iPodTouch1G: return " iPod Touch 1G "
137
146
case . iPodTouch2G: return " iPod Touch 2G "
138
147
case . iPodTouch3G: return " iPod Touch 3G "
@@ -181,7 +190,10 @@ internal enum DeviceType: String, EnumProtocol {
181
190
case . iPhone8: return [ " iPhone10,1 " , " iPhone10,4 " ]
182
191
case . iPhone8Plus: return [ " iPhone10,2 " , " iPhone10,5 " ]
183
192
case . iPhoneX: return [ " iPhone10,3 " , " iPhone10,6 " ]
184
-
193
+ case . iPhoneXS: return [ " iPhone11,2 " ]
194
+ case . iPhoneXSMax: return [ " iPhone11,4 " , " iPhone11,6 " ]
195
+ case . iPhoneXR: return [ " iPhone11,8 " ]
196
+
185
197
case . iPodTouch1G: return [ " iPod1,1 " ]
186
198
case . iPodTouch2G: return [ " iPod2,1 " ]
187
199
case . iPodTouch3G: return [ " iPod3,1 " ]
@@ -224,29 +236,51 @@ internal enum DeviceType: String, EnumProtocol {
224
236
}
225
237
}
226
238
227
-
228
- // MARK: - EnumProtocol
229
- internal protocol EnumProtocol : Hashable {
230
- /// -returns: All Enum Values
231
- static var all : [ Self ] { get }
232
- }
233
-
234
- // MARK: -
235
- // MARK: - Extensions
236
- internal extension EnumProtocol {
237
-
238
- static var all : [ Self ] {
239
- typealias Type = Self
240
- let cases = AnySequence { ( ) -> AnyIterator < Type > in
241
- var raw = 0
242
- return AnyIterator {
243
- let current : Self = withUnsafePointer ( to: & raw) { $0. withMemoryRebound ( to: Type . self, capacity: 1 ) { $0. pointee } }
244
- guard current. hashValue == raw else { return nil }
245
- raw += 1
246
- return current
247
- }
248
- }
249
-
250
- return Array ( cases)
239
+ extension DeviceType {
240
+ static var all : [ DeviceType ] {
241
+ return [
242
+ iPhone2G,
243
+ iPhone3G,
244
+ iPhone3GS,
245
+ iPhone4,
246
+ iPhone4S,
247
+ iPhone5,
248
+ iPhone5C,
249
+ iPhone5S,
250
+ iPhone6,
251
+ iPhone6Plus,
252
+ iPhone6S,
253
+ iPhone6SPlus,
254
+ iPhoneSE,
255
+ iPhone7,
256
+ iPhone7Plus,
257
+ iPhone8,
258
+ iPhone8Plus,
259
+ iPhoneX,
260
+ iPhoneXS,
261
+ iPhoneXSMax,
262
+ iPhoneXR,
263
+ iPodTouch1G,
264
+ iPodTouch2G,
265
+ iPodTouch3G,
266
+ iPodTouch4G,
267
+ iPodTouch5G,
268
+ iPodTouch6G,
269
+ iPad,
270
+ iPad2,
271
+ iPad3,
272
+ iPad4,
273
+ iPadMini,
274
+ iPadMiniRetina,
275
+ iPadMini3,
276
+ iPadMini4,
277
+ iPadAir,
278
+ iPadAir2,
279
+ iPadPro9Inch,
280
+ iPadPro10p5Inch,
281
+ iPadPro12Inch,
282
+ simulator,
283
+ notAvailable
284
+ ]
251
285
}
252
286
}
0 commit comments