Skip to content

Commit 496ff7f

Browse files
authored
Merge pull request #234 from tidev/feature/xcode-15-1_7_X
2 parents f312832 + 981c8e9 commit 496ff7f

File tree

4 files changed

+122
-5
lines changed

4 files changed

+122
-5
lines changed

lib/simctl.js

+67
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ exports.getSim = getSim;
2525
exports.install = install;
2626
exports.launch = launch;
2727
exports.list = list;
28+
exports.listDevices = listDevices;
2829
exports.pair = pair;
2930
exports.pairAndActivate = pairAndActivate;
3031
exports.shutdown = shutdown;
@@ -246,6 +247,72 @@ function list(params, callback) {
246247
);
247248
}
248249

250+
251+
/**
252+
* Returns a list of all devices.
253+
*
254+
* @param {Object} params - Various parameters.
255+
* @param {String} params.simctl - The path to the `simctl` executable.
256+
* @param {Number} [params.tries] - The max number of `simctl` tries.
257+
* @param {Function} callback(err, info) - A function to call when finished.
258+
*/
259+
function listDevices(params, callback) {
260+
if (!params || typeof params !== 'object') {
261+
return callback(new Error(__('Missing params')));
262+
}
263+
if (!params.simctl) {
264+
return callback(new Error(__('Missing "simctl" param')));
265+
}
266+
267+
var done = false;
268+
var tries = 0;
269+
var maxTries = params.tries || 4;
270+
271+
async.whilst(
272+
function (cb) {
273+
return cb(null, !done && tries++ < maxTries);
274+
},
275+
function (cb) {
276+
trySimctl(params, ['list', 'devices', '--json'], function (err, output) {
277+
if (err) {
278+
return cb(err);
279+
}
280+
281+
output = output.trim();
282+
if (!output) {
283+
log('simctl list devices output was empty!');
284+
return cb();
285+
}
286+
287+
var json = null;
288+
try {
289+
json = JSON.parse(output.substring(output.indexOf('{')));
290+
} catch (e) {
291+
return cb(e);
292+
}
293+
294+
if (!json) {
295+
return cb(new Error(__('simctl list devices: json is null')));
296+
}
297+
298+
done = true;
299+
cb(null, json);
300+
});
301+
},
302+
function (err, info) {
303+
if (err) {
304+
return callback(err);
305+
}
306+
307+
if (!done) {
308+
return callback(new Error(__('simctl list devices failed after %s tries', maxTries)));
309+
}
310+
311+
callback(null, info);
312+
}
313+
);
314+
}
315+
249316
/**
250317
* Pairs a iOS Simulator with a watchOS Simulator.
251318
*

lib/xcode.js

+52-2
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,38 @@ const simulatorDevicePairCompatibility = {
237237
'8.x': true, // watchOS 8.x
238238
'9.x': true // watchOS 9.x
239239
}
240+
},
241+
'15.x': { // Xcode 15.x
242+
'13.x': { // iOS 13.x
243+
'7.x': true, // watchOS 7.x
244+
'8.x': true, // watchOS 8.x
245+
'9.x': true, // watchOS 9.x
246+
'10.x': true // watchOS 10.x
247+
},
248+
'14.x': { // iOS 14.x
249+
'7.x': true, // watchOS 7.x
250+
'8.x': true, // watchOS 8.x
251+
'9.x': true, // watchOS 9.x
252+
'10.x': true // watchOS 10.x
253+
},
254+
'15.x': {
255+
'7.x': true, // watchOS 7.x
256+
'8.x': true, // watchOS 8.x
257+
'9.x': true, // watchOS 9.x
258+
'10.x': true // watchOS 10.x
259+
},
260+
'16.x': {
261+
'7.x': true, // watchOS 7.x
262+
'8.x': true, // watchOS 8.x
263+
'9.x': true, // watchOS 9.x
264+
'10.x': true // watchOS 10.x
265+
},
266+
'17.x': {
267+
'7.x': true, // watchOS 7.x
268+
'8.x': true, // watchOS 8.x
269+
'9.x': true, // watchOS 9.x
270+
'10.x': true // watchOS 10.x
271+
}
240272
}
241273
};
242274

@@ -556,8 +588,26 @@ exports.detect = function detect(options, callback) {
556588
}
557589
});
558590

559-
// read in the runtimes
560-
appc.util.mix(xc.simRuntimes, findSimRuntimes(path.join(deviceTypePath, 'Runtimes')));
591+
simctl.listDevices({ simctl: xc.executables.simctl }, function (err, info) {
592+
if (err) {
593+
return next(err);
594+
}
595+
596+
// Map the platform and version from CoreSimulator string like:
597+
// - com.apple.CoreSimulator.SimRuntime.iOS-17-0
598+
// - com.apple.CoreSimulator.SimRuntime.watchOS-10-0
599+
for (const key of Object.keys(info.devices)) {
600+
const [_, platform, rawVersion] = key.match(/\.SimRuntime\.(.*?)\-(.*)$/);
601+
const version = rawVersion.replaceAll('-', '.');
602+
603+
const mapping = {
604+
name: `${platform} ${version}`,
605+
version
606+
}
607+
appc.util.mix(xc.simRuntimes, { [key]: mapping });
608+
609+
}
610+
});
561611
});
562612

563613
['Simulator', 'iOS Simulator'].some(function (name) {

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ioslib",
3-
"version": "1.7.31",
3+
"version": "1.7.32",
44
"description": "iOS Utility Library",
55
"keywords": [
66
"appcelerator",

0 commit comments

Comments
 (0)