Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace ios-deploy with devicectl #2614

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/cli-doctor/src/tools/healthchecks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import androidSDK from './androidSDK';
import androidNDK from './androidNDK';
import xcode from './xcode';
import cocoaPods from './cocoaPods';
import iosDeploy from './iosDeploy';
import {Healthchecks, HealthCheckCategory} from '../../types';
import {loadConfigAsync} from '@react-native-community/cli-config';
import xcodeEnv from './xcodeEnv';
Expand Down Expand Up @@ -93,7 +92,7 @@ export const getHealthchecks = async ({
? {
ios: {
label: 'iOS',
healthchecks: [xcode, ruby, cocoaPods, iosDeploy],
healthchecks: [xcode, ruby, cocoaPods],
},
}
: {}),
Expand Down
35 changes: 0 additions & 35 deletions packages/cli-doctor/src/tools/healthchecks/iosDeploy.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Options = {
udid: string;
binaryPath?: string;
platform?: ApplePlatform;
isSimulator?: boolean;
};

export default async function installApp({
Expand All @@ -39,6 +40,7 @@ export default async function installApp({
udid,
binaryPath,
platform,
isSimulator = true,
}: Options) {
let appPath = binaryPath;

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

if (udid && appPath) {
child_process.spawnSync('xcrun', ['simctl', 'install', udid, appPath], {
const installParameters = isSimulator
? ['simctl', 'install', udid, appPath]
: ['devicectl', 'device', 'install', 'app', '--device', udid, appPath];

child_process.spawnSync('xcrun', installParameters, {
stdio: 'inherit',
});
}
Expand All @@ -91,12 +97,11 @@ export default async function installApp({

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

let result = child_process.spawnSync('xcrun', [
'simctl',
'launch',
udid,
bundleID,
]);
const launchParameters = isSimulator
? ['simctl', 'launch', udid, bundleID]
: ['devicectl', 'device', 'process', 'launch', '--device', udid, bundleID];

const result = child_process.spawnSync('xcrun', launchParameters);

handleLaunchResult(
result.status === 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import child_process from 'child_process';
import {ApplePlatform, Device} from '../../types';
import {IOSProjectInfo} from '@react-native-community/cli-types';
import {CLIError, logger} from '@react-native-community/cli-tools';
import chalk from 'chalk';
import {buildProject} from '../buildCommand/buildProject';
import {getBuildPath} from './getBuildPath';
import {FlagsT} from './createRun';
import {getBuildSettings} from './getBuildSettings';
import installApp from './installApp';

export async function runOnDevice(
selectedDevice: Device,
Expand All @@ -22,20 +22,6 @@ export async function runOnDevice(
);
}

const isIOSDeployInstalled = child_process.spawnSync(
'ios-deploy',
['--version'],
{encoding: 'utf8'},
);

if (isIOSDeployInstalled.error) {
throw new CLIError(
`Failed to install the app on the device because we couldn't execute the "ios-deploy" command. Please install it by running "${chalk.bold(
'brew install ios-deploy',
)}" and try again.`,
);
}

if (selectedDevice.type === 'catalyst') {
const buildOutput = await buildProject(
xcodeProject,
Expand Down Expand Up @@ -64,8 +50,10 @@ export async function runOnDevice(
});
appProcess.unref();
} else {
let buildOutput, appPath;
if (!args.binaryPath) {
const {binaryPath, target} = args;

let buildOutput;
if (!binaryPath) {
buildOutput = await buildProject(
xcodeProject,
platform,
Expand All @@ -74,44 +62,20 @@ export async function runOnDevice(
scheme,
args,
);

const buildSettings = await getBuildSettings(
xcodeProject,
mode,
buildOutput,
scheme,
);

if (!buildSettings) {
throw new CLIError('Failed to get build settings for your project');
}

appPath = await getBuildPath(buildSettings, platform);
} else {
appPath = args.binaryPath;
}

const iosDeployInstallArgs = [
'--bundle',
appPath,
'--id',
selectedDevice.udid,
'--justlaunch',
];

logger.info(`Installing and launching your app on ${selectedDevice.name}`);

const iosDeployOutput = child_process.spawnSync(
'ios-deploy',
iosDeployInstallArgs,
{encoding: 'utf8'},
);

if (iosDeployOutput.error) {
throw new CLIError(
`Failed to install the app on the device. We've encountered an error in "ios-deploy" command: ${iosDeployOutput.error.message}`,
);
}
installApp({
buildOutput: buildOutput ?? '',
xcodeProject,
mode,
scheme,
target,
udid: selectedDevice.udid,
binaryPath,
isSimulator: false,
});
}

return logger.success('Installed the app on the device.');
Expand Down
Loading