diff --git a/packages/platform-ios/src/commands/runIOS/__tests__/parseIOSDevicesList.test.ts b/packages/platform-ios/src/commands/runIOS/__tests__/parseIOSDevicesList.test.ts index 2a2639a12..8131252db 100644 --- a/packages/platform-ios/src/commands/runIOS/__tests__/parseIOSDevicesList.test.ts +++ b/packages/platform-ios/src/commands/runIOS/__tests__/parseIOSDevicesList.test.ts @@ -29,6 +29,10 @@ describe('parseIOSDevicesList', () => { ); expect(devices).toEqual([ + { + name: 'Maxs MacBook Pro', + udid: '11111111-1111-1111-1111-111111111111', + }, { name: "Max's iPhone", udid: '11111111111111111111aaaaaaaaaaaaaaaaaaaa', diff --git a/packages/platform-ios/src/commands/runIOS/index.ts b/packages/platform-ios/src/commands/runIOS/index.ts index 4024eb28b..63e958fec 100644 --- a/packages/platform-ios/src/commands/runIOS/index.ts +++ b/packages/platform-ios/src/commands/runIOS/index.ts @@ -83,7 +83,8 @@ function runIOS(_: Array, ctx: Config, args: FlagsT) { }), ); - if (devices.length === 0) { + // first device is always the host Mac + if (devices.length <= 1) { return logger.error('No iOS devices connected.'); } diff --git a/packages/platform-ios/src/commands/runIOS/parseIOSDevicesList.ts b/packages/platform-ios/src/commands/runIOS/parseIOSDevicesList.ts index 0416d27ff..b3ab45936 100644 --- a/packages/platform-ios/src/commands/runIOS/parseIOSDevicesList.ts +++ b/packages/platform-ios/src/commands/runIOS/parseIOSDevicesList.ts @@ -9,13 +9,30 @@ import {Device} from '../../types'; /** * Parses the output of `xcrun simctl list devices` command + * Expected text looks roughly like this: + * Known Devices: + * this-mac-device [ID] + * Some Apple Simulator (Version) [ID] */ function parseIOSDevicesList(text: string): Array { const devices: Array = []; - text.split('\n').forEach(line => { + text.split('\n').forEach((line, index) => { const device = line.match(/(.*?) \((.*?)\) \[(.*?)\]/); const noSimulator = line.match(/(.*?) \((.*?)\) \[(.*?)\] \((.*?)\)/); + + if (index === 1) { + const myMac = line.match(/(.*?) \[(.*?)\]/); + if (myMac) { + const name = myMac[1]; + const udid = myMac[2]; + devices.push({ + udid, + name, + }); + } + } + if (device != null && noSimulator == null) { const name = device[1]; const version = device[2];