Skip to content

Commit f52c39e

Browse files
Lucas Bentodratwas
authored andcommitted
feat: check ios-deploy installation before proceeding to build on device (react-native-community#332)
Summary: --------- This PR fixes react-native-community#330, it checks if `ios-deploy` is installed or not before it actually starts building. Test Plan: ---------- - Run `npm uninstall -g ios-deploy`; - Run the CLI with `--device` argument and wait for it to fail; - Run `npm i -g ios-deploy`; - Run the CLI again and see it working. cc @thymikee --- ### Error about `ios-deploy` not installed ![image](https://user-images.githubusercontent.com/6207220/56423345-e7d5f800-62ab-11e9-9acf-e5336685904a.png) ### Random error when executing `ios-deploy` ![image](https://user-images.githubusercontent.com/6207220/56423377-12c04c00-62ac-11e9-863a-82c12800893a.png)
1 parent 5c85ad6 commit f52c39e

File tree

1 file changed

+20
-4
lines changed
  • packages/platform-ios/src/commands/runIOS

1 file changed

+20
-4
lines changed

packages/platform-ios/src/commands/runIOS/index.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,20 @@ async function runOnSimulator(xcodeProject, scheme, args: FlagsT) {
190190
}
191191

192192
async function runOnDevice(selectedDevice, scheme, xcodeProject, args: FlagsT) {
193+
const isIOSDeployInstalled = child_process.spawnSync(
194+
'ios-deploy',
195+
['--version'],
196+
{encoding: 'utf8'},
197+
);
198+
199+
if (isIOSDeployInstalled.error) {
200+
throw new CLIError(
201+
`Failed to install the app on the device because we couldn't execute the "ios-deploy" command. Please install it by running "${chalk.bold(
202+
'npm install -g ios-deploy',
203+
)}" and try again.`,
204+
);
205+
}
206+
193207
const appName = await buildProject(
194208
xcodeProject,
195209
selectedDevice.udid,
@@ -214,12 +228,14 @@ async function runOnDevice(selectedDevice, scheme, xcodeProject, args: FlagsT) {
214228
);
215229

216230
if (iosDeployOutput.error) {
217-
logger.error(
218-
'** INSTALLATION FAILED **\nMake sure you have ios-deploy installed globally.\n(e.g "npm install -g ios-deploy")',
231+
throw new CLIError(
232+
`Failed to install the app on the device. We've encountered an error in "ios-deploy" command: ${
233+
iosDeployOutput.error.message
234+
}`,
219235
);
220-
} else {
221-
logger.info('** INSTALLATION SUCCEEDED **');
222236
}
237+
238+
return logger.success('Installed the app on the device.');
223239
}
224240

225241
function buildProject(xcodeProject, udid, scheme, args: FlagsT) {

0 commit comments

Comments
 (0)