diff --git a/packages/cli/src/runIOS/findMatchingSimulator.js b/packages/cli/src/runIOS/findMatchingSimulator.js index 31a7a0b12..b4ac690e7 100644 --- a/packages/cli/src/runIOS/findMatchingSimulator.js +++ b/packages/cli/src/runIOS/findMatchingSimulator.js @@ -39,7 +39,15 @@ function findMatchingSimulator(simulators, simulatorString) { } let match; - for (const version in devices) { + for (const versionDescriptor in devices) { + const device = devices[versionDescriptor]; + let version = versionDescriptor; + + if ((/^com\.apple\.CoreSimulator\.SimRuntime\./g).test(version)) { + // Transform "com.apple.CoreSimulator.SimRuntime.iOS-12-2" into "iOS 12.2" + version = version.replace(/^com\.apple\.CoreSimulator\.SimRuntime\.([^-]+)-([^-]+)-([^-]+)$/g, '$1 $2.$3'); + } + // Making sure the version of the simulator is an iOS or tvOS (Removes Apple Watch, etc) if (!version.startsWith('iOS') && !version.startsWith('tvOS')) { continue; @@ -47,8 +55,8 @@ function findMatchingSimulator(simulators, simulatorString) { if (simulatorVersion && !version.endsWith(simulatorVersion)) { continue; } - for (const i in devices[version]) { - const simulator = devices[version][i]; + for (const i in device) { + const simulator = device[i]; // Skipping non-available simulator if ( simulator.availability !== '(available)' &&