From 40dccc48259167187f25beac92f86dd1635d79a8 Mon Sep 17 00:00:00 2001 From: Ruslan Lesiutin Date: Tue, 4 Oct 2022 12:46:27 +0100 Subject: [PATCH] feat(ios): use Bundler for pods installation --- packages/cli-doctor/src/tools/installPods.ts | 11 +++++---- .../cli-doctor/src/tools/runBundleInstall.ts | 23 +++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 packages/cli-doctor/src/tools/runBundleInstall.ts diff --git a/packages/cli-doctor/src/tools/installPods.ts b/packages/cli-doctor/src/tools/installPods.ts index f8846c2c2..146caef3f 100644 --- a/packages/cli-doctor/src/tools/installPods.ts +++ b/packages/cli-doctor/src/tools/installPods.ts @@ -5,6 +5,7 @@ import prompts from 'prompts'; import {logger, NoopLoader} from '@react-native-community/cli-tools'; // @ts-ignore untyped import sudo from 'sudo-prompt'; +import runBundleInstall from './runBundleInstall'; import {brewInstall} from './brewInstall'; import {Loader} from '../types'; @@ -24,7 +25,8 @@ async function runPodInstall( '(this may take a few minutes)', )}`, ); - await execa('pod', ['install']); + + await execa('bundle', ['exec', 'pod', 'install']); } catch (error) { // "pod" command outputs errors to stdout (at least some of them) const stderr = error.stderr || error.stdout; @@ -41,10 +43,10 @@ async function runPodInstall( await runPodInstall(loader, directory, false); } else { loader.fail(); + logger.error(stderr); + throw new Error( - `Failed to install CocoaPods dependencies for iOS project, which is required by this template.\nPlease try again manually: "cd ./${directory}/ios && pod install".\nCocoaPods documentation: ${chalk.dim.underline( - 'https://cocoapods.org/', - )}`, + 'Looks like your iOS environment is not properly set. Please go to https://reactnative.dev/docs/next/environment-setup and follow the React Native CLI QuickStart guide for macOS and iOS.', ); } } @@ -191,6 +193,7 @@ async function installPods({ await installCocoaPods(loader); } + await runBundleInstall(loader); await runPodInstall(loader, directory); } catch (error) { throw error; diff --git a/packages/cli-doctor/src/tools/runBundleInstall.ts b/packages/cli-doctor/src/tools/runBundleInstall.ts new file mode 100644 index 000000000..c129b8819 --- /dev/null +++ b/packages/cli-doctor/src/tools/runBundleInstall.ts @@ -0,0 +1,23 @@ +import execa from 'execa'; +import {logger} from '@react-native-community/cli-tools'; + +import {Loader} from '../types'; + +async function runBundleInstall(loader: Loader) { + try { + loader.start('Installing Bundler'); + + await execa('bundle', ['install']); + } catch (error) { + loader.fail(); + logger.error(error.stderr || error.stdout); + + throw new Error( + 'Looks like your iOS environment is not properly set. Please go to https://reactnative.dev/docs/next/environment-setup and follow the React Native CLI QuickStart guide for macOS and iOS.', + ); + } + + loader.succeed(); +} + +export default runBundleInstall;