@@ -141,6 +141,7 @@ function getDeviceFromDeviceTypeId(devicetypeid) {
141
141
142
142
var options = { 'silent' : true } ;
143
143
var list = simctl . list ( options ) . json ;
144
+ list = fixSimCtlList ( list ) ;
144
145
145
146
var arr = [ ] ;
146
147
if ( devicetypeid ) {
@@ -265,6 +266,44 @@ function filterDeviceName(deviceName) {
265
266
return deviceName ;
266
267
}
267
268
269
+ function fixNameKey ( array , mapping ) {
270
+ if ( ! array || ! mapping ) {
271
+ return array ;
272
+ }
273
+
274
+ return array . map ( function ( elem ) {
275
+ var name = mapping [ elem . name ] ;
276
+ if ( name ) {
277
+ elem . name = name ;
278
+ }
279
+ return elem ;
280
+ } ) ;
281
+ }
282
+
283
+ function fixSimCtlList ( list ) {
284
+ // Xcode 9 `xcrun simctl list devicetypes` have obfuscated names for 2017 iPhones and Apple Watches.
285
+ var deviceTypeNameMap = {
286
+ 'iPhone2017-A' : 'iPhone 8' ,
287
+ 'iPhone2017-B' : 'iPhone 8 Plus' ,
288
+ 'iPhone2017-C' : 'iPhone X' ,
289
+ 'Watch2017 - 38mm' : 'Apple Watch Series 3 - 38mm' ,
290
+ 'Watch2017 - 42mm' : 'Apple Watch Series 3 - 42mm'
291
+ } ;
292
+ list . devicetypes = fixNameKey ( list . devicetypes , deviceTypeNameMap ) ;
293
+
294
+ // `iPad Pro` in iOS 9.3 has mapped to `iPad Pro (9.7 inch)`
295
+ // `Apple TV 1080p` has mapped to `Apple TV`
296
+ var deviceNameMap = {
297
+ 'Apple TV 1080p' : 'Apple TV' ,
298
+ 'iPad Pro' : 'iPad Pro (9.7-inch)'
299
+ } ;
300
+ Object . keys ( list . devices ) . forEach ( function ( key ) {
301
+ list . devices [ key ] = fixNameKey ( list . devices [ key ] , deviceNameMap ) ;
302
+ } ) ;
303
+
304
+ return list ;
305
+ }
306
+
268
307
var lib = {
269
308
270
309
init : function ( ) {
@@ -287,6 +326,7 @@ var lib = {
287
326
showsdks : function ( args ) {
288
327
var options = { silent : true , runtimes : true } ;
289
328
var list = simctl . list ( options ) . json ;
329
+ list = fixSimCtlList ( list ) ;
290
330
291
331
console . log ( 'Simulator SDK Roots:' ) ;
292
332
list . runtimes . forEach ( function ( runtime ) {
@@ -302,6 +342,7 @@ var lib = {
302
342
getdevicetypes : function ( args ) {
303
343
var options = { silent : true } ;
304
344
var list = simctl . list ( options ) . json ;
345
+ list = fixSimCtlList ( list ) ;
305
346
306
347
var druntimes = findRuntimesGroupByDeviceProperty ( list , 'name' , true ) ;
307
348
var name_id_map = { } ;
@@ -327,6 +368,9 @@ var lib = {
327
368
var dname = filterDeviceName ( deviceName ) ;
328
369
329
370
if ( ! ( dname in name_id_map ) ) {
371
+
372
+ console . log ( '----> DNAME' , dname ) ;
373
+ console . log ( '----> RUNTIMES' , runtimes ) ;
330
374
continue ;
331
375
}
332
376
0 commit comments