Skip to content

Commit

Permalink
feat: support run-ios on Mac target (Catalyst) (#1024)
Browse files Browse the repository at this point in the history
* feat: support run-ios on Mac target (Catalyst)

* fix: fix parseIOSDevicesList test

* fix: remove unreachable condition

* fix: add some comments

* fix: update comment
  • Loading branch information
robertying authored Mar 11, 2020
1 parent 3f37b39 commit 6ce799f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion packages/platform-ios/src/commands/runIOS/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ function runIOS(_: Array<string>, 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.');
}

Expand Down
19 changes: 18 additions & 1 deletion packages/platform-ios/src/commands/runIOS/parseIOSDevicesList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Device> {
const devices: Array<Device> = [];

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];
Expand Down

0 comments on commit 6ce799f

Please sign in to comment.