Skip to content

Commit 6ce55a2

Browse files
authored
feat: Replace ios-deploy with devicectl (#2614)
- Remove ios-deploy healthcheck - Update installApp to support simulators & devices - Remove ios-deploy from runOnDevices
1 parent 7647359 commit 6ce55a2

File tree

4 files changed

+28
-95
lines changed

4 files changed

+28
-95
lines changed

packages/cli-doctor/src/tools/healthchecks/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import androidSDK from './androidSDK';
1010
import androidNDK from './androidNDK';
1111
import xcode from './xcode';
1212
import cocoaPods from './cocoaPods';
13-
import iosDeploy from './iosDeploy';
1413
import {Healthchecks, HealthCheckCategory} from '../../types';
1514
import {loadConfigAsync} from '@react-native-community/cli-config';
1615
import xcodeEnv from './xcodeEnv';
@@ -93,7 +92,7 @@ export const getHealthchecks = async ({
9392
? {
9493
ios: {
9594
label: 'iOS',
96-
healthchecks: [xcode, ruby, cocoaPods, iosDeploy],
95+
healthchecks: [xcode, ruby, cocoaPods],
9796
},
9897
}
9998
: {}),

packages/cli-doctor/src/tools/healthchecks/iosDeploy.ts

-35
This file was deleted.

packages/cli-platform-apple/src/commands/runCommand/installApp.ts

+12-7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type Options = {
2828
udid: string;
2929
binaryPath?: string;
3030
platform?: ApplePlatform;
31+
isSimulator?: boolean;
3132
};
3233

3334
export default async function installApp({
@@ -39,6 +40,7 @@ export default async function installApp({
3940
udid,
4041
binaryPath,
4142
platform,
43+
isSimulator = true,
4244
}: Options) {
4345
let appPath = binaryPath;
4446

@@ -72,7 +74,11 @@ export default async function installApp({
7274
logger.info(`Installing "${chalk.bold(appPath)}`);
7375

7476
if (udid && appPath) {
75-
child_process.spawnSync('xcrun', ['simctl', 'install', udid, appPath], {
77+
const installParameters = isSimulator
78+
? ['simctl', 'install', udid, appPath]
79+
: ['devicectl', 'device', 'install', 'app', '--device', udid, appPath];
80+
81+
child_process.spawnSync('xcrun', installParameters, {
7682
stdio: 'inherit',
7783
});
7884
}
@@ -91,12 +97,11 @@ export default async function installApp({
9197

9298
logger.info(`Launching "${chalk.bold(bundleID)}"`);
9399

94-
let result = child_process.spawnSync('xcrun', [
95-
'simctl',
96-
'launch',
97-
udid,
98-
bundleID,
99-
]);
100+
const launchParameters = isSimulator
101+
? ['simctl', 'launch', udid, bundleID]
102+
: ['devicectl', 'device', 'process', 'launch', '--device', udid, bundleID];
103+
104+
const result = child_process.spawnSync('xcrun', launchParameters);
100105

101106
handleLaunchResult(
102107
result.status === 0,

packages/cli-platform-apple/src/commands/runCommand/runOnDevice.ts

+15-51
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import child_process from 'child_process';
22
import {ApplePlatform, Device} from '../../types';
33
import {IOSProjectInfo} from '@react-native-community/cli-types';
44
import {CLIError, logger} from '@react-native-community/cli-tools';
5-
import chalk from 'chalk';
65
import {buildProject} from '../buildCommand/buildProject';
76
import {getBuildPath} from './getBuildPath';
87
import {FlagsT} from './createRun';
98
import {getBuildSettings} from './getBuildSettings';
9+
import installApp from './installApp';
1010

1111
export async function runOnDevice(
1212
selectedDevice: Device,
@@ -22,20 +22,6 @@ export async function runOnDevice(
2222
);
2323
}
2424

25-
const isIOSDeployInstalled = child_process.spawnSync(
26-
'ios-deploy',
27-
['--version'],
28-
{encoding: 'utf8'},
29-
);
30-
31-
if (isIOSDeployInstalled.error) {
32-
throw new CLIError(
33-
`Failed to install the app on the device because we couldn't execute the "ios-deploy" command. Please install it by running "${chalk.bold(
34-
'brew install ios-deploy',
35-
)}" and try again.`,
36-
);
37-
}
38-
3925
if (selectedDevice.type === 'catalyst') {
4026
const buildOutput = await buildProject(
4127
xcodeProject,
@@ -64,8 +50,10 @@ export async function runOnDevice(
6450
});
6551
appProcess.unref();
6652
} else {
67-
let buildOutput, appPath;
68-
if (!args.binaryPath) {
53+
const {binaryPath, target} = args;
54+
55+
let buildOutput;
56+
if (!binaryPath) {
6957
buildOutput = await buildProject(
7058
xcodeProject,
7159
platform,
@@ -74,44 +62,20 @@ export async function runOnDevice(
7462
scheme,
7563
args,
7664
);
77-
78-
const buildSettings = await getBuildSettings(
79-
xcodeProject,
80-
mode,
81-
buildOutput,
82-
scheme,
83-
);
84-
85-
if (!buildSettings) {
86-
throw new CLIError('Failed to get build settings for your project');
87-
}
88-
89-
appPath = await getBuildPath(buildSettings, platform);
90-
} else {
91-
appPath = args.binaryPath;
9265
}
9366

94-
const iosDeployInstallArgs = [
95-
'--bundle',
96-
appPath,
97-
'--id',
98-
selectedDevice.udid,
99-
'--justlaunch',
100-
];
101-
10267
logger.info(`Installing and launching your app on ${selectedDevice.name}`);
10368

104-
const iosDeployOutput = child_process.spawnSync(
105-
'ios-deploy',
106-
iosDeployInstallArgs,
107-
{encoding: 'utf8'},
108-
);
109-
110-
if (iosDeployOutput.error) {
111-
throw new CLIError(
112-
`Failed to install the app on the device. We've encountered an error in "ios-deploy" command: ${iosDeployOutput.error.message}`,
113-
);
114-
}
69+
installApp({
70+
buildOutput: buildOutput ?? '',
71+
xcodeProject,
72+
mode,
73+
scheme,
74+
target,
75+
udid: selectedDevice.udid,
76+
binaryPath,
77+
isSimulator: false,
78+
});
11579
}
11680

11781
return logger.success('Installed the app on the device.');

0 commit comments

Comments
 (0)