@@ -2,11 +2,11 @@ import child_process from 'child_process';
2
2
import { ApplePlatform , Device } from '../../types' ;
3
3
import { IOSProjectInfo } from '@react-native-community/cli-types' ;
4
4
import { CLIError , logger } from '@react-native-community/cli-tools' ;
5
- import chalk from 'chalk' ;
6
5
import { buildProject } from '../buildCommand/buildProject' ;
7
6
import { getBuildPath } from './getBuildPath' ;
8
7
import { FlagsT } from './createRun' ;
9
8
import { getBuildSettings } from './getBuildSettings' ;
9
+ import installApp from './installApp' ;
10
10
11
11
export async function runOnDevice (
12
12
selectedDevice : Device ,
@@ -22,20 +22,6 @@ export async function runOnDevice(
22
22
) ;
23
23
}
24
24
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
-
39
25
if ( selectedDevice . type === 'catalyst' ) {
40
26
const buildOutput = await buildProject (
41
27
xcodeProject ,
@@ -64,8 +50,10 @@ export async function runOnDevice(
64
50
} ) ;
65
51
appProcess . unref ( ) ;
66
52
} else {
67
- let buildOutput , appPath ;
68
- if ( ! args . binaryPath ) {
53
+ const { binaryPath, target} = args ;
54
+
55
+ let buildOutput ;
56
+ if ( ! binaryPath ) {
69
57
buildOutput = await buildProject (
70
58
xcodeProject ,
71
59
platform ,
@@ -74,44 +62,20 @@ export async function runOnDevice(
74
62
scheme ,
75
63
args ,
76
64
) ;
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 ;
92
65
}
93
66
94
- const iosDeployInstallArgs = [
95
- '--bundle' ,
96
- appPath ,
97
- '--id' ,
98
- selectedDevice . udid ,
99
- '--justlaunch' ,
100
- ] ;
101
-
102
67
logger . info ( `Installing and launching your app on ${ selectedDevice . name } ` ) ;
103
68
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
+ } ) ;
115
79
}
116
80
117
81
return logger . success ( 'Installed the app on the device.' ) ;
0 commit comments