Skip to content

Commit 1376ab6

Browse files
committed
perf: use devicectl instead of xcdevice; refactor Device
1 parent 3800e9d commit 1376ab6

5 files changed

Lines changed: 559 additions & 415 deletions

File tree

packages/plugin-platform-apple/src/lib/commands/run/createRun.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path from 'path';
22
import fs from 'fs';
33
import isInteractive from 'is-interactive';
44
import { logger } from '@callstack/rnef-tools';
5-
import listDevices from '../../utils/listDevices.js';
5+
import { listDevicesAndSimulators } from '../../utils/listDevices.js';
66
import { promptForDeviceSelection } from '../../utils/prompts.js';
77
import { getConfiguration } from '../build/getConfiguration.js';
88
import { getPlatformInfo } from '../../utils/getPlatformInfo.js';
@@ -26,9 +26,7 @@ export const createRun = async (
2626
args: RunFlags,
2727
projectRoot: string
2828
) => {
29-
const { sdkNames, readableName: platformReadableName } =
30-
getPlatformInfo(platformName);
31-
29+
const { readableName: platformReadableName } = getPlatformInfo(platformName);
3230
const { xcodeProject, sourceDir } = projectConfig;
3331

3432
if (!xcodeProject) {
@@ -57,14 +55,14 @@ export const createRun = async (
5755

5856
const loader = spinner();
5957
loader.start('Looking for available devices and simulators');
60-
const devices = await listDevices(sdkNames);
58+
const devices = await listDevicesAndSimulators();
6159
if (devices.length === 0) {
6260
return logger.error(
6361
`${platformReadableName} devices or simulators not detected. Install simulators via Xcode or connect a physical ${platformReadableName} device`
6462
);
6563
}
6664
loader.stop('Found available devices and simulators.');
67-
const device = await selectDevice(devices, args, projectRoot, platformName);
65+
const device = await selectDevice(devices, args, platformName);
6866

6967
if (device) {
7068
if (device.type === 'simulator') {
@@ -124,7 +122,6 @@ export const createRun = async (
124122
async function selectDevice(
125123
devices: Device[],
126124
args: RunFlags,
127-
projectRoot: string,
128125
platform: ApplePlatform
129126
) {
130127
const { simulator, udid, interactive } = args;

packages/plugin-platform-apple/src/lib/types/index.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,9 @@ export type ApplePlatform = ObjectValues<typeof supportedPlatforms>;
77
export interface Device {
88
name: string;
99
udid: string;
10-
state?: string;
11-
availability?: string;
12-
isAvailable?: boolean;
13-
version?: string;
14-
sdk?: string;
15-
availabilityError?: string;
16-
type?: DeviceType;
17-
lastBootedAt?: string;
10+
version: string;
11+
type: DeviceType;
12+
state?: 'Booted' | 'Shutdown';
1813
}
1914

2015
export type DeviceType = 'simulator' | 'device' | 'catalyst';

0 commit comments

Comments
 (0)