Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ios): use Bundler for pods installation #1708

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this line does not appear in the successful run posted in the Test Plan? 🤔

Copy link
Contributor Author

@hoxyq hoxyq Oct 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this line does not appear in the successful run posted in the Test Plan? 🤔

Looks like I need to make a separate loader.succeed call, will fix that


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;