@@ -2,11 +2,11 @@ import child_process from 'child_process';
22import { ApplePlatform , Device } from '../../types' ;
33import { IOSProjectInfo } from '@react-native-community/cli-types' ;
44import { CLIError , logger } from '@react-native-community/cli-tools' ;
5- import chalk from 'chalk' ;
65import { buildProject } from '../buildCommand/buildProject' ;
76import { getBuildPath } from './getBuildPath' ;
87import { FlagsT } from './createRun' ;
98import { getBuildSettings } from './getBuildSettings' ;
9+ import installApp from './installApp' ;
1010
1111export 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