@@ -49,13 +49,18 @@ public enum Device {
49
49
case iPhone6s
50
50
/// - iPhone6sPlus: All iPhone 6s Plus variants.
51
51
case iPhone6sPlus
52
- /// - iPhoneSE: iPhone SE.
52
+ /// - iPhoneSE: All iPhone SE variants .
53
53
case iPhoneSE
54
54
/// - iPhone7: All iPhone 7 variants.
55
55
case iPhone7
56
56
/// - iPhone7Plus: All iPhone 7 Plus variants.
57
57
case iPhone7Plus
58
-
58
+ /// - iPhone8: All iPhone 8 variants.
59
+ case iPhone8
60
+ /// - iPhone8Plus: All iPhone 8 Plus variants.
61
+ case iPhone8Plus
62
+ /// - iPhoneX: All iPhone X variants.
63
+ case iPhoneX
59
64
60
65
/// - iPad2: All iPad 2 variants.
61
66
case iPad2
@@ -94,12 +99,17 @@ public enum Device {
94
99
/// - appleTV4: Apple TV 4.
95
100
case appleTV4
96
101
102
+ /// - appleTV4K: Apple TV 4K.
103
+ case appleTV4K
104
+
97
105
/// - watch: The original Apple Watch.
98
106
case watch
99
107
/// - watchSeries1: Apple Watch Series 1.
100
108
case watchSeries1
101
109
/// - watchSeries2: Apple Watch Series 2.
102
110
case watchSeries2
111
+ /// - watchSeries3: Apple Watch Series 3.
112
+ case watchSeries3
103
113
104
114
/// - simulator: A simulator for the associated device model.
105
115
indirect case simulator( Device )
@@ -109,44 +119,48 @@ public enum Device {
109
119
110
120
/// All real-device values.
111
121
public static let allValues : [ Device ] = [
112
- . iPhone4S,
113
- . iPhone5,
114
- . iPhone5c,
115
- . iPhone5s,
116
- . iPhone6,
117
- . iPhone6Plus,
118
- . iPhone6s,
119
- . iPhone6sPlus,
120
- . iPhoneSE,
121
- . iPhone7,
122
- . iPhone7Plus,
123
- . iPodTouch5G,
124
- . iPodTouch6G,
125
- . appleTV4,
126
- . watch,
127
- . watchSeries1,
128
- . watchSeries2,
129
- . iPad2,
130
- . iPad3,
131
- . iPad4,
132
- . iPad5,
133
- . iPadAir,
134
- . iPadAir2,
135
- . iPadPro12Inch,
136
- . iPadPro9Inch,
137
- . iPadPro12Inch2G,
138
- . iPadPro10Inch,
139
- . iPadMini,
140
- . iPadMini2,
141
- . iPadMini3,
142
- . iPadMini4,
122
+ . iPhone4S,
123
+ . iPhone5,
124
+ . iPhone5c,
125
+ . iPhone5s,
126
+ . iPhone6,
127
+ . iPhone6Plus,
128
+ . iPhone6s,
129
+ . iPhone6sPlus,
130
+ . iPhoneSE,
131
+ . iPhone7,
132
+ . iPhone7Plus,
133
+ . iPhone8,
134
+ . iPhone8Plus,
135
+ . iPhoneX,
136
+ . iPodTouch5G,
137
+ . iPodTouch6G,
138
+ . appleTV4,
139
+ . appleTV4K,
140
+ . watch,
141
+ . watchSeries1,
142
+ . watchSeries2,
143
+ . watchSeries3,
144
+ . iPad2,
145
+ . iPad3,
146
+ . iPad4,
147
+ . iPad5,
148
+ . iPadAir,
149
+ . iPadAir2,
150
+ . iPadPro12Inch,
151
+ . iPadPro9Inch,
152
+ . iPadPro12Inch2G,
153
+ . iPadPro10Inch,
154
+ . iPadMini,
155
+ . iPadMini2,
156
+ . iPadMini3,
157
+ . iPadMini4,
143
158
]
144
159
145
160
}
146
161
147
162
public extension Device {
148
163
149
-
150
164
/// Inspects the current device.
151
165
public init ( ) {
152
166
self = RawDevice ( identifier: nil ) . device!
@@ -158,14 +172,12 @@ public extension Device {
158
172
///
159
173
/// - Parameter identifier: A device identifier, e.g. "iPhone9,2", "iPad6,11.", "AppleTV5,3".
160
174
public init ? ( identifier: String ? = nil ) {
161
- guard let thingy = RawDevice ( identifier: identifier) . device
175
+ guard let device = RawDevice ( identifier: identifier) . device
162
176
else {
163
177
return nil
164
178
}
165
-
166
- self = thingy
179
+ self = device
167
180
}
168
-
169
181
}
170
182
171
183
// MARK: - Errors
@@ -194,19 +206,24 @@ public extension Device {
194
206
. iPhone6sPlus,
195
207
. iPhoneSE,
196
208
. iPhone7,
197
- . iPhone7Plus:
209
+ . iPhone7Plus,
210
+ . iPhone8,
211
+ . iPhone8Plus,
212
+ . iPhoneX:
198
213
return . phone
199
214
200
215
case . iPodTouch5G,
201
216
. iPodTouch6G:
202
217
return . pod
203
218
204
- case . appleTV4:
219
+ case . appleTV4,
220
+ . appleTV4K:
205
221
return . tv
206
222
207
223
case . watch,
208
224
. watchSeries1,
209
- . watchSeries2:
225
+ . watchSeries2,
226
+ . watchSeries3:
210
227
return . watch
211
228
212
229
case . iPad2,
@@ -267,6 +284,12 @@ internal extension Device {
267
284
return [ 9.1 , 9.3 ]
268
285
case . iPhone7Plus:
269
286
return [ 9.2 , 9.4 ]
287
+ case . iPhone8:
288
+ return [ 10.1 , 10.4 ]
289
+ case . iPhone8Plus:
290
+ return [ 10.2 , 10.5 ]
291
+ case . iPhoneX:
292
+ return [ 10.3 , 10.6 ]
270
293
271
294
case . iPodTouch5G:
272
295
return [ 5.1 ]
@@ -275,13 +298,17 @@ internal extension Device {
275
298
276
299
case . appleTV4:
277
300
return [ 5.3 ]
301
+ case . appleTV4K:
302
+ return [ 6.2 ]
278
303
279
304
case . watch:
280
305
return [ 1.1 , 1.2 ]
281
306
case . watchSeries1:
282
307
return [ 2.6 , 2.7 ]
283
308
case . watchSeries2:
284
309
return [ 2.3 , 2.4 ]
310
+ case . watchSeries3:
311
+ return [ 3.1 , 3.2 , 3.3 , 3.4 ]
285
312
286
313
case . iPad2:
287
314
return [ 2.1 , 2.2 , 2.3 , 2.4 ]
@@ -393,6 +420,12 @@ extension Device: MarketingProtocol {
393
420
return " iPhone 7 "
394
421
case . iPhone7Plus:
395
422
return " iPhone 7 Plus "
423
+ case . iPhone8:
424
+ return " iPhone 8 "
425
+ case . iPhone8Plus:
426
+ return " iPhone 8 Plus "
427
+ case . iPhoneX:
428
+ return " iPhone X "
396
429
397
430
case . iPad2:
398
431
return " iPad 2 "
@@ -415,28 +448,32 @@ extension Device: MarketingProtocol {
415
448
case . iPadAir2:
416
449
return " iPad Air 2 "
417
450
case . iPadPro12Inch:
418
- return " iPad Pro ( 12.9 inch) "
451
+ return " 12.9- inch iPad Pro "
419
452
case . iPadPro9Inch:
420
- return " iPad Pro ( 9.7 inch) "
453
+ return " 9.7- inch iPad Pro "
421
454
case . iPadPro12Inch2G:
422
- return " iPad Pro ( 12.9 inch) (2nd generation)"
455
+ return " 12.9- inch iPad Pro (2nd generation) "
423
456
case . iPadPro10Inch:
424
- return " iPad Pro ( 10.5 inch) "
457
+ return " 10.5- inch iPad Pro "
425
458
426
459
case . iPodTouch5G:
427
460
return " iPod touch (5th generation) "
428
461
case . iPodTouch6G:
429
462
return " iPod touch (6th generation) "
430
463
431
464
case . appleTV4:
432
- return " Apple TV 4 "
465
+ return " Apple TV "
466
+ case . appleTV4K:
467
+ return " Apple TV 4K "
433
468
434
469
case . watch:
435
470
return " Apple Watch "
436
471
case . watchSeries1:
437
472
return " Apple Watch Series 1 "
438
473
case . watchSeries2:
439
474
return " Apple Watch Series 2 "
475
+ case . watchSeries3:
476
+ return " Apple Watch Series 3 "
440
477
441
478
case let . simulator( model) :
442
479
return NSLocalizedString ( " Simulator ( \( model. marketingName) ) " , comment: " Simulator ( \( model. marketingName) ) " )
@@ -453,7 +490,6 @@ extension Device: MarketingProtocol {
453
490
454
491
public extension Device {
455
492
456
-
457
493
/// Returns the display size in inches.
458
494
public var displaySize : Display . Size {
459
495
return display. size
@@ -463,60 +499,85 @@ public extension Device {
463
499
public var display : Display {
464
500
switch self {
465
501
case . iPhone4S:
466
- return Display ( size: . screen3_5Inch, resolution: CGSize ( width: 320 , height: 480 ) , physicalResolution: CGSize ( width: 640 , height: 960 ) , renderedResolution: CGSize ( width: 640 , height: 960 ) , scale: 2.0 , density: 326 )
502
+ return Display ( size: . screen3_5Inch, resolution: CGSize ( width: 320 , height: 480 ) , physicalResolution: CGSize ( width: 640 , height: 960 ) , renderedResolution: CGSize ( width: 640 , height: 960 ) , scale: 2.0 , density: 326 , hasTrueTone : false , colorSpace : . sRGB )
467
503
468
504
case . iPhone5,
469
505
. iPhone5c,
470
506
. iPhone5s,
471
507
. iPhoneSE,
472
508
. iPodTouch5G,
473
509
. iPodTouch6G:
474
- return Display ( size: . screen4Inch, resolution: CGSize ( width: 320 , height: 568 ) , physicalResolution: CGSize ( width: 640 , height: 1136 ) , renderedResolution: CGSize ( width: 640 , height: 1136 ) , scale: 2.0 , density: 326 )
510
+ return Display ( size: . screen4Inch, resolution: CGSize ( width: 320 , height: 568 ) , physicalResolution: CGSize ( width: 640 , height: 1136 ) , renderedResolution: CGSize ( width: 640 , height: 1136 ) , scale: 2.0 , density: 326 , hasTrueTone : false , colorSpace : . sRGB )
475
511
476
512
case . iPhone6,
477
- . iPhone6s,
478
- . iPhone7:
479
- return Display ( size: . screen4_7Inch, resolution: CGSize ( width: 375 , height: 667 ) , physicalResolution: CGSize ( width: 750 , height: 1334 ) , renderedResolution: CGSize ( width: 750 , height: 1334 ) , scale: 2.0 , density: 326 )
513
+ . iPhone6s:
514
+ return Display ( size: . screen4_7Inch, resolution: CGSize ( width: 375 , height: 667 ) , physicalResolution: CGSize ( width: 750 , height: 1334 ) , renderedResolution: CGSize ( width: 750 , height: 1334 ) , scale: 2.0 , density: 326 , hasTrueTone: false , colorSpace: . sRGB)
515
+
516
+ case . iPhone7:
517
+ return Display ( size: . screen4_7Inch, resolution: CGSize ( width: 375 , height: 667 ) , physicalResolution: CGSize ( width: 750 , height: 1334 ) , renderedResolution: CGSize ( width: 750 , height: 1334 ) , scale: 2.0 , density: 326 , hasTrueTone: false , colorSpace: . p3)
518
+
519
+ case . iPhone8:
520
+ return Display ( size: . screen4_7Inch, resolution: CGSize ( width: 375 , height: 667 ) , physicalResolution: CGSize ( width: 750 , height: 1334 ) , renderedResolution: CGSize ( width: 750 , height: 1334 ) , scale: 2.0 , density: 326 , hasTrueTone: true , colorSpace: . p3)
480
521
481
522
case . iPhone6Plus,
482
- . iPhone6sPlus,
483
- . iPhone7Plus:
484
- return Display ( size: . screen5_5Inch, resolution: CGSize ( width: 414 , height: 736 ) , physicalResolution: CGSize ( width: 1080 , height: 1920 ) , renderedResolution: CGSize ( width: 1242 , height: 2208 ) , scale: 3.0 , density: 401 )
523
+ . iPhone6sPlus:
524
+ return Display ( size: . screen5_5Inch, resolution: CGSize ( width: 414 , height: 736 ) , physicalResolution: CGSize ( width: 1080 , height: 1920 ) , renderedResolution: CGSize ( width: 1242 , height: 2208 ) , scale: 3.0 , density: 401 , hasTrueTone: false , colorSpace: . sRGB)
525
+
526
+ case . iPhone7Plus:
527
+ return Display ( size: . screen5_5Inch, resolution: CGSize ( width: 414 , height: 736 ) , physicalResolution: CGSize ( width: 1080 , height: 1920 ) , renderedResolution: CGSize ( width: 1242 , height: 2208 ) , scale: 3.0 , density: 401 , hasTrueTone: false , colorSpace: . p3)
528
+
529
+ case . iPhone8Plus:
530
+ return Display ( size: . screen5_5Inch, resolution: CGSize ( width: 414 , height: 736 ) , physicalResolution: CGSize ( width: 1080 , height: 1920 ) , renderedResolution: CGSize ( width: 1242 , height: 2208 ) , scale: 3.0 , density: 401 , hasTrueTone: true , colorSpace: . p3)
531
+
532
+ case . iPhoneX:
533
+ return Display ( size: . screen5_8Inch, resolution: CGSize ( width: 375 , height: 812 ) , physicalResolution: CGSize ( width: 2436 , height: 1125 ) , renderedResolution: CGSize ( width: 1242 , height: 2208 ) , scale: 3.0 , density: 458 , hasTrueTone: true , colorSpace: . p3)
485
534
486
535
case . appleTV4:
487
- return Display ( size: . notApplicable, resolution: CGSize ( width: 1920 , height: 1080 ) , physicalResolution: CGSize ( width: 1920 , height: 1080 ) , renderedResolution: CGSize ( width: 1920 , height: 1080 ) , scale: 1.0 , density: 0 )
536
+ return Display ( size: . notApplicable, resolution: CGSize ( width: 1920 , height: 1080 ) , physicalResolution: CGSize ( width: 1920 , height: 1080 ) , renderedResolution: CGSize ( width: 1920 , height: 1080 ) , scale: 1.0 , density: 0 , hasTrueTone: false , colorSpace: . sRGB)
537
+
538
+ case . appleTV4K:
539
+ return Display ( size: . notApplicable, resolution: CGSize ( width: 3840 , height: 2160 ) , physicalResolution: CGSize ( width: 3840 , height: 2160 ) , renderedResolution: CGSize ( width: 3840 , height: 2160 ) , scale: 1.0 , density: 0 , hasTrueTone: false , colorSpace: . sRGB)
488
540
489
541
case . iPad2:
490
- return Display ( size: . screen9_7Inch, resolution: CGSize ( width: 1024 , height: 768 ) , physicalResolution: CGSize ( width: 1024 , height: 768 ) , renderedResolution: CGSize ( width: 1024 , height: 768 ) , scale: 1.0 , density: 132 )
542
+ return Display ( size: . screen9_7Inch, resolution: CGSize ( width: 1024 , height: 768 ) , physicalResolution: CGSize ( width: 1024 , height: 768 ) , renderedResolution: CGSize ( width: 1024 , height: 768 ) , scale: 1.0 , density: 132 , hasTrueTone : false , colorSpace : . sRGB )
491
543
492
544
case . iPad3,
493
545
. iPad4,
494
546
. iPad5,
495
547
. iPadAir,
496
- . iPadAir2,
497
- . iPadPro9Inch:
498
- return Display ( size: . screen9_7Inch, resolution: CGSize ( width: 1024 , height: 768 ) , physicalResolution: CGSize ( width: 2048 , height: 1536 ) , renderedResolution: CGSize ( width: 2048 , height: 1536 ) , scale: 2.0 , density: 264 )
499
- case . iPadPro12Inch,
500
- . iPadPro12Inch2G:
501
- return Display ( size: . screen12_9Inch, resolution: CGSize ( width: 1366 , height: 1024 ) , physicalResolution: CGSize ( width: 2732 , height: 2048 ) , renderedResolution: CGSize ( width: 2732 , height: 2048 ) , scale: 2.0 , density: 264 )
548
+ . iPadAir2:
549
+ return Display ( size: . screen9_7Inch, resolution: CGSize ( width: 1024 , height: 768 ) , physicalResolution: CGSize ( width: 2048 , height: 1536 ) , renderedResolution: CGSize ( width: 2048 , height: 1536 ) , scale: 2.0 , density: 264 , hasTrueTone: false , colorSpace: . sRGB)
550
+
551
+ case . iPadPro12Inch:
552
+ return Display ( size: . screen12_9Inch, resolution: CGSize ( width: 1366 , height: 1024 ) , physicalResolution: CGSize ( width: 2732 , height: 2048 ) , renderedResolution: CGSize ( width: 2732 , height: 2048 ) , scale: 2.0 , density: 264 , hasTrueTone: false , colorSpace: . sRGB)
553
+
554
+ case . iPadPro9Inch:
555
+ return Display ( size: . screen9_7Inch, resolution: CGSize ( width: 1024 , height: 768 ) , physicalResolution: CGSize ( width: 2048 , height: 1536 ) , renderedResolution: CGSize ( width: 2048 , height: 1536 ) , scale: 2.0 , density: 264 , hasTrueTone: true , colorSpace: . p3)
556
+
557
+ case . iPadPro12Inch2G:
558
+ return Display ( size: . screen12_9Inch, resolution: CGSize ( width: 1366 , height: 1024 ) , physicalResolution: CGSize ( width: 2732 , height: 2048 ) , renderedResolution: CGSize ( width: 2732 , height: 2048 ) , scale: 2.0 , density: 264 , hasTrueTone: true , colorSpace: . p3)
559
+
502
560
case . iPadPro10Inch:
503
- return Display ( size: . screen12_9Inch, resolution: CGSize ( width: 1112 , height: 834 ) , physicalResolution: CGSize ( width: 2224 , height: 1668 ) , renderedResolution: CGSize ( width: 2224 , height: 1668 ) , scale: 2.0 , density: 264 )
561
+ return Display ( size: . screen12_9Inch, resolution: CGSize ( width: 1112 , height: 834 ) , physicalResolution: CGSize ( width: 2224 , height: 1668 ) , renderedResolution: CGSize ( width: 2224 , height: 1668 ) , scale: 2.0 , density: 264 , hasTrueTone: true , colorSpace: . p3)
562
+
504
563
case . iPadMini:
505
- return Display ( size: . screen7_9Inch, resolution: CGSize ( width: 1024 , height: 768 ) , physicalResolution: CGSize ( width: 1024 , height: 768 ) , renderedResolution: CGSize ( width: 1024 , height: 768 ) , scale: 1.0 , density: 163 )
564
+ return Display ( size: . screen7_9Inch, resolution: CGSize ( width: 1024 , height: 768 ) , physicalResolution: CGSize ( width: 1024 , height: 768 ) , renderedResolution: CGSize ( width: 1024 , height: 768 ) , scale: 1.0 , density: 163 , hasTrueTone: false , colorSpace: . sRGB)
565
+
506
566
case . iPadMini2,
507
567
. iPadMini3,
508
568
. iPadMini4:
509
- return Display ( size: . screen7_9Inch, resolution: CGSize ( width: 1024 , height: 768 ) , physicalResolution: CGSize ( width: 2048 , height: 1536 ) , renderedResolution: CGSize ( width: 2048 , height: 1536 ) , scale: 2.0 , density: 326 )
569
+ return Display ( size: . screen7_9Inch, resolution: CGSize ( width: 1024 , height: 768 ) , physicalResolution: CGSize ( width: 2048 , height: 1536 ) , renderedResolution: CGSize ( width: 2048 , height: 1536 ) , scale: 2.0 , density: 326 , hasTrueTone : false , colorSpace : . sRGB )
510
570
511
571
case let . simulator( model) :
512
572
return model. display
513
573
514
- // FIXME: Add a way to inspect the Apple Watch displays.
574
+ // FIXME: Add a way to inspect the Apple Watch displays.
515
575
case . unknown( _) ,
516
576
. watch,
517
577
. watchSeries1,
518
- . watchSeries2:
519
- return Display ( size: . notApplicable, resolution: CGSize . zero, physicalResolution: CGSize . zero, renderedResolution: CGSize . zero, scale: 0 , density: 0 )
578
+ . watchSeries2,
579
+ . watchSeries3:
580
+ return Display ( size: . notApplicable, resolution: CGSize . zero, physicalResolution: CGSize . zero, renderedResolution: CGSize . zero, scale: 0 , density: 0 , hasTrueTone: false , colorSpace: . sRGB)
520
581
}
521
582
}
522
583
@@ -526,7 +587,6 @@ public extension Device {
526
587
527
588
public extension Device {
528
589
529
-
530
590
/// Checks if the current device is the same as the compared model.
531
591
///
532
592
/// - Parameter to: A model to compare the current device against.
0 commit comments