From aa13b5bc1507081aeb6888e66a974517c2776773 Mon Sep 17 00:00:00 2001 From: Rui Ying Date: Thu, 27 Feb 2020 21:26:36 +0800 Subject: [PATCH 1/5] feat: support run-ios on Mac target (Catalyst) --- .../platform-ios/src/commands/runIOS/index.ts | 3 +++ .../src/commands/runIOS/parseIOSDevicesList.ts | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/platform-ios/src/commands/runIOS/index.ts b/packages/platform-ios/src/commands/runIOS/index.ts index 4024eb28b..f45018656 100644 --- a/packages/platform-ios/src/commands/runIOS/index.ts +++ b/packages/platform-ios/src/commands/runIOS/index.ts @@ -84,6 +84,9 @@ function runIOS(_: Array, ctx: Config, args: FlagsT) { ); if (devices.length === 0) { + return logger.error('No Mac or iOS devices connected.'); // which should never happen when running on 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..04f3939c6 100644 --- a/packages/platform-ios/src/commands/runIOS/parseIOSDevicesList.ts +++ b/packages/platform-ios/src/commands/runIOS/parseIOSDevicesList.ts @@ -13,9 +13,22 @@ import {Device} from '../../types'; 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]; From d89d51d5d5c0b4b335e3ea10188ecf151107a316 Mon Sep 17 00:00:00 2001 From: Rui Ying Date: Thu, 27 Feb 2020 21:43:40 +0800 Subject: [PATCH 2/5] fix: fix parseIOSDevicesList test --- .../src/commands/runIOS/__tests__/parseIOSDevicesList.test.ts | 4 ++++ 1 file changed, 4 insertions(+) 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', From dd3801c50b742c043773c270e65937b1b9fd504b Mon Sep 17 00:00:00 2001 From: Rui Ying Date: Thu, 27 Feb 2020 21:51:47 +0800 Subject: [PATCH 3/5] fix: remove unreachable condition --- packages/platform-ios/src/commands/runIOS/index.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/platform-ios/src/commands/runIOS/index.ts b/packages/platform-ios/src/commands/runIOS/index.ts index f45018656..079b74356 100644 --- a/packages/platform-ios/src/commands/runIOS/index.ts +++ b/packages/platform-ios/src/commands/runIOS/index.ts @@ -83,9 +83,6 @@ function runIOS(_: Array, ctx: Config, args: FlagsT) { }), ); - if (devices.length === 0) { - return logger.error('No Mac or iOS devices connected.'); // which should never happen when running on Mac - } if (devices.length === 1) { return logger.error('No iOS devices connected.'); } From 525c838d1e32ad272ed09642255b13d6819321ca Mon Sep 17 00:00:00 2001 From: Rui Ying Date: Thu, 27 Feb 2020 21:59:35 +0800 Subject: [PATCH 4/5] fix: add some comments --- packages/platform-ios/src/commands/runIOS/index.ts | 3 ++- .../platform-ios/src/commands/runIOS/parseIOSDevicesList.ts | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/platform-ios/src/commands/runIOS/index.ts b/packages/platform-ios/src/commands/runIOS/index.ts index 079b74356..f67cf67c0 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 === 1) { + // first device is usually a 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 04f3939c6..b3ab45936 100644 --- a/packages/platform-ios/src/commands/runIOS/parseIOSDevicesList.ts +++ b/packages/platform-ios/src/commands/runIOS/parseIOSDevicesList.ts @@ -9,6 +9,10 @@ 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 = []; From 5410128924aaba3634d165a1cfe8e86de03bc4a3 Mon Sep 17 00:00:00 2001 From: Rui Ying Date: Wed, 11 Mar 2020 23:53:24 +0800 Subject: [PATCH 5/5] fix: update comment --- packages/platform-ios/src/commands/runIOS/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platform-ios/src/commands/runIOS/index.ts b/packages/platform-ios/src/commands/runIOS/index.ts index f67cf67c0..63e958fec 100644 --- a/packages/platform-ios/src/commands/runIOS/index.ts +++ b/packages/platform-ios/src/commands/runIOS/index.ts @@ -83,7 +83,7 @@ function runIOS(_: Array, ctx: Config, args: FlagsT) { }), ); - // first device is usually a host Mac + // first device is always the host Mac if (devices.length <= 1) { return logger.error('No iOS devices connected.'); }