Skip to content

Commit ae01760

Browse files
committed
fix: xcode 10.2 compatibility for run-ios command
parse output of simulator list provided by xcode 10.2 In Xcode 10.2, the output of `xcrun simctl list --json devices` has changed to include a namespace within each version group. This commit makes a backwards-compatible adjustment to account for this change in format. To illustrate: Before ====== ``` { "devices": { "iOS 10.0": [ ... ] } } ``` After ===== ``` { "devices": { "com.apple.CoreSimulator.SimRuntime.iOS-10-0": [ ... ] } } ```
1 parent b33d079 commit ae01760

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Diff for: packages/cli/src/runIOS/findMatchingSimulator.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,24 @@ function findMatchingSimulator(simulators, simulatorString) {
3939
}
4040

4141
let match;
42-
for (const version in devices) {
42+
for (const versionDescriptor in devices) {
43+
const device = devices[versionDescriptor];
44+
let version = versionDescriptor;
45+
46+
if ((/^com\.apple\.CoreSimulator\.SimRuntime\./g).test(version)) {
47+
// Transform "com.apple.CoreSimulator.SimRuntime.iOS-12-2" into "iOS 12.2"
48+
version = version.replace(/^com\.apple\.CoreSimulator\.SimRuntime\.([^-]+)-([^-]+)-([^-]+)$/g, '$1 $2.$3');
49+
}
50+
4351
// Making sure the version of the simulator is an iOS or tvOS (Removes Apple Watch, etc)
4452
if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {
4553
continue;
4654
}
4755
if (simulatorVersion && !version.endsWith(simulatorVersion)) {
4856
continue;
4957
}
50-
for (const i in devices[version]) {
51-
const simulator = devices[version][i];
58+
for (const i in device) {
59+
const simulator = device[i];
5260
// Skipping non-available simulator
5361
if (
5462
simulator.availability !== '(available)' &&

0 commit comments

Comments
 (0)