Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions lib/simctl.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ exports.getSim = getSim;
exports.install = install;
exports.launch = launch;
exports.list = list;
exports.listDevices = listDevices;
exports.pair = pair;
exports.pairAndActivate = pairAndActivate;
exports.shutdown = shutdown;
Expand Down Expand Up @@ -246,6 +247,72 @@ function list(params, callback) {
);
}


/**
* Returns a list of all devices.
*
* @param {Object} params - Various parameters.
* @param {String} params.simctl - The path to the `simctl` executable.
* @param {Number} [params.tries] - The max number of `simctl` tries.
* @param {Function} callback(err, info) - A function to call when finished.
*/
function listDevices(params, callback) {
if (!params || typeof params !== 'object') {
return callback(new Error(__('Missing params')));
}
if (!params.simctl) {
return callback(new Error(__('Missing "simctl" param')));
}

var done = false;
var tries = 0;
var maxTries = params.tries || 4;

async.whilst(
function (cb) {
return cb(null, !done && tries++ < maxTries);
},
function (cb) {
trySimctl(params, ['list', 'devices', '--json'], function (err, output) {
if (err) {
return cb(err);
}

output = output.trim();
if (!output) {
log('simctl list devices output was empty!');
return cb();
}

var json = null;
try {
json = JSON.parse(output.substring(output.indexOf('{')));
} catch (e) {
return cb(e);
}

if (!json) {
return cb(new Error(__('simctl list devices: json is null')));
}

done = true;
cb(null, json);
});
},
function (err, info) {
if (err) {
return callback(err);
}

if (!done) {
return callback(new Error(__('simctl list devices failed after %s tries', maxTries)));
}

callback(null, info);
}
);
}

/**
* Pairs a iOS Simulator with a watchOS Simulator.
*
Expand Down
54 changes: 52 additions & 2 deletions lib/xcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,38 @@ const simulatorDevicePairCompatibility = {
'8.x': true, // watchOS 8.x
'9.x': true // watchOS 9.x
}
},
'15.x': { // Xcode 15.x
'13.x': { // iOS 13.x
'7.x': true, // watchOS 7.x
'8.x': true, // watchOS 8.x
'9.x': true, // watchOS 9.x
'10.x': true // watchOS 10.x
},
'14.x': { // iOS 14.x
'7.x': true, // watchOS 7.x
'8.x': true, // watchOS 8.x
'9.x': true, // watchOS 9.x
'10.x': true // watchOS 10.x
},
'15.x': {
'7.x': true, // watchOS 7.x
'8.x': true, // watchOS 8.x
'9.x': true, // watchOS 9.x
'10.x': true // watchOS 10.x
},
'16.x': {
'7.x': true, // watchOS 7.x
'8.x': true, // watchOS 8.x
'9.x': true, // watchOS 9.x
'10.x': true // watchOS 10.x
},
'17.x': {
'7.x': true, // watchOS 7.x
'8.x': true, // watchOS 8.x
'9.x': true, // watchOS 9.x
'10.x': true // watchOS 10.x
}
}
};

Expand Down Expand Up @@ -556,8 +588,26 @@ exports.detect = function detect(options, callback) {
}
});

// read in the runtimes
appc.util.mix(xc.simRuntimes, findSimRuntimes(path.join(deviceTypePath, 'Runtimes')));
simctl.listDevices({ simctl: xc.executables.simctl }, function (err, info) {
if (err) {
return next(err);
}

// Map the platform and version from CoreSimulator string like:
// - com.apple.CoreSimulator.SimRuntime.iOS-17-0
// - com.apple.CoreSimulator.SimRuntime.watchOS-10-0
for (const key of Object.keys(info.devices)) {
const [_, platform, rawVersion] = key.match(/\.SimRuntime\.(.*?)\-(.*)$/);
const version = rawVersion.replaceAll('-', '.');

const mapping = {
name: `${platform} ${version}`,
version
}
appc.util.mix(xc.simRuntimes, { [key]: mapping });

}
});
});

['Simulator', 'iOS Simulator'].some(function (name) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ioslib",
"version": "1.7.31",
"version": "1.7.32",
"description": "iOS Utility Library",
"keywords": [
"appcelerator",
Expand Down