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 c0acc80
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/cli/src/runIOS/findMatchingSimulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ function findMatchingSimulator(simulators, simulatorString) {
}

let match;
for (const version in devices) {
for (const versionDescriptor in devices) {
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;
Expand Down

0 comments on commit c0acc80

Please sign in to comment.