Skip to content

use pod installed by bundler if possible #2669

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

buschco
Copy link

@buschco buschco commented Jun 3, 2025

Summary

see #2668

This change ensures that local installed cocoapods (bundle exec pod) is used before system installed pod.

Test Plan

A: Bundled Version:

  1. make sure no cocoapods is not installed globally: gem uninstall cocoapods
  2. npx @react-native-community/cli@latest init MyApp
  3. press n for cocoa pods question
  4. cd MyApp
  5. bundle install

Now bundle exec pod --version has an 0 exit code.

npx react-native run-ios --force-pods will not fail nor install cocoapods globally (pod will have exit code > 0)

B: Global Version (someone could argue this should never be supported anyway):

  1. make sure cocoapods is installed globally: gem install cocoapods
  2. npx @react-native-community/cli@latest init MyApp
  3. press n for cocoa pods question
  4. cd MyApp
  5. remove cocoapods from Gemfile
  6. bundle install

Now bundle exec pod --version has an non 0 exit code.

npx react-native run-ios --force-pods will not fail and install cocoapods globally (pod will have non 0 exit code)

Checklist

  • Documentation is up to date.
  • Follows commit message convention described in CONTRIBUTING.md.
  • For functional changes, my test plan has linked these CLI changes into a local react-native checkout (instructions).

export async function execaPod(args: string[], options?: execa.Options) {
let podType: 'system' | 'bundle' = 'system';
try {
await execa('bundle', ['exec', 'pod', '--version'], options);
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be quicker to run bundle show cocoapods. That way it doesn't need to initialise cocoapods, it just asks bundler if it can resolve it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Whether it remains as an bundle exec pod --version or becomes a bundle show cocoapods;

Does this need to be more robust?

I'm asking because currently, it'd fail if bundle install hasn't been run and would then fall back to the system pod even if it's meant to be using bundler.

If the first command fails you could potentially check the output of bundle check to see if cocoapods is listed as a missing gem?

But, this may be more complex than it needs to be? I'll defer to a project maintainer on that one. 😄

Copy link
Author

Choose a reason for hiding this comment

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

I'm asking because currently, it'd fail if bundle install hasn't been run and would then fall back to the system pod even if it's meant to be using bundler.

Nice catch. This would move more users to installing cocoapods globally, but it seems this is not the intended way since the template that is used by the cli is installing cocoapods with bundler anyway (https://github.com/react-native-community/template/blob/main/template/Gemfile#L7).

It would be a breaking change in but I would love to have only the bundler way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants