Permalink
Browse files

Shows devicetypes for new iPhones, Apple Watches released fall 2017 (#…

…219)

* Shows devicetypes for new iPhones, Apple Watches released fall 2017

This closes #218
  • Loading branch information...
shazron committed Sep 15, 2017
1 parent 4bbe6b3 commit c5445c1c94a1333273fdbde055888ced8adf1574
Showing with 44 additions and 0 deletions.
  1. +44 −0 src/lib.js
View
@@ -141,6 +141,7 @@ function getDeviceFromDeviceTypeId(devicetypeid) {
var options = { 'silent': true };
var list = simctl.list(options).json;
list = fixSimCtlList(list);
var arr = [];
if (devicetypeid) {
@@ -265,6 +266,44 @@ function filterDeviceName(deviceName) {
return deviceName;
}
function fixNameKey(array, mapping) {
if (!array || !mapping) {
return array;
}
return array.map(function(elem) {
var name = mapping[elem.name];
if (name) {
elem.name = name;
}
return elem;
});
}
function fixSimCtlList(list) {
// Xcode 9 `xcrun simctl list devicetypes` have obfuscated names for 2017 iPhones and Apple Watches.
var deviceTypeNameMap = {
'iPhone2017-A': 'iPhone 8',
'iPhone2017-B': 'iPhone 8 Plus',
'iPhone2017-C': 'iPhone X',
'Watch2017 - 38mm': 'Apple Watch Series 3 - 38mm',
'Watch2017 - 42mm': 'Apple Watch Series 3 - 42mm'
};
list.devicetypes = fixNameKey(list.devicetypes, deviceTypeNameMap);
// `iPad Pro` in iOS 9.3 has mapped to `iPad Pro (9.7 inch)`
// `Apple TV 1080p` has mapped to `Apple TV`
var deviceNameMap = {
'Apple TV 1080p': 'Apple TV',
'iPad Pro': 'iPad Pro (9.7-inch)'
};
Object.keys(list.devices).forEach(function(key) {
list.devices[key] = fixNameKey(list.devices[key], deviceNameMap);
});
return list;
}
var lib = {
init: function() {
@@ -287,6 +326,7 @@ var lib = {
showsdks: function(args) {
var options = { silent: true, runtimes: true };
var list = simctl.list(options).json;
list = fixSimCtlList(list);
console.log('Simulator SDK Roots:');
list.runtimes.forEach(function(runtime) {
@@ -302,6 +342,7 @@ var lib = {
getdevicetypes: function(args) {
var options = { silent: true };
var list = simctl.list(options).json;
list = fixSimCtlList(list);
var druntimes = findRuntimesGroupByDeviceProperty(list, 'name', true);
var name_id_map = {};
@@ -327,6 +368,9 @@ var lib = {
var dname = filterDeviceName(deviceName);
if (!(dname in name_id_map)) {
console.log('----> DNAME', dname);
console.log('----> RUNTIMES', runtimes);
continue;
}

0 comments on commit c5445c1

Please sign in to comment.