Skip to content

Commit

Permalink
feat(ios): use Bundler for pods installation (react-native-community#…
Browse files Browse the repository at this point in the history
…1708)

Co-authored-by: Ruslan Lesiutin <[email protected]>
  • Loading branch information
hoxyq and Ruslan Lesiutin authored Oct 4, 2022
1 parent 7963c59 commit 49a945d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/cli-doctor/src/tools/installPods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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;
Expand All @@ -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.',
);
}
}
Expand Down Expand Up @@ -191,6 +193,7 @@ async function installPods({
await installCocoaPods(loader);
}

await runBundleInstall(loader);
await runPodInstall(loader, directory);
} catch (error) {
throw error;
Expand Down
23 changes: 23 additions & 0 deletions packages/cli-doctor/src/tools/runBundleInstall.ts
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 49a945d

Please sign in to comment.