Skip to content

Commit

Permalink
fix: xcode 10.2 compatibility for run-ios command
Browse files Browse the repository at this point in the history
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": [
      ...
    ]
  }
}
```
  • Loading branch information
canterberry committed Jan 31, 2019
1 parent b33d079 commit ae01760
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/cli/src/runIOS/findMatchingSimulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,24 @@ 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;
}
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)' &&
Expand Down

0 comments on commit ae01760

Please sign in to comment.