cli icon indicating copy to clipboard operation
cli copied to clipboard

Use of `pod` and `bundle exec pod`

Open jankosecki opened this issue 7 months ago • 1 comments

I've noticed that as part of recent update to CLI, run-ios builds CocoaPods dependencies.

There seems to be a bit of inconsistency because in installPods CLI checks if pod command is available (https://github.com/react-native-community/cli/blob/a856ce027a6b25f9363a8689311cdd4416c0fc89/packages/cli-config-apple/src/tools/installPods.ts#L154C7-L154C18) and shortly after in runPodInstall it uses bundle exec pod install instead.

I can see that some other parts of CLI use pod CLI directly (await execa('pod', ['cache', 'clean', '--all'], and await execa('pod', ['repo', 'update']);) but wouldn't it make more sense to always call pod through bundle exec?

Up until today I didn't need global pod CLI installed on my machine as I was always uses bundle instead

jankosecki avatar May 19 '25 15:05 jankosecki

I opened a similar issue https://github.com/react-native-community/cli/issues/2668 that shares the same root cause.

However I submitted an PR https://github.com/react-native-community/cli/pull/2669 that addresses this issue and your issue.

Until then you can use this patch to use only the Cocoapods installed by bundler:

patches/@react-native-community+cli-config-apple+18.0.0.patch

diff --git a/node_modules/@react-native-community/cli-config-apple/build/tools/installPods.js b/node_modules/@react-native-community/cli-config-apple/build/tools/installPods.js
index fc52a47..217d71b 100644
--- a/node_modules/@react-native-community/cli-config-apple/build/tools/installPods.js
+++ b/node_modules/@react-native-community/cli-config-apple/build/tools/installPods.js
@@ -75,7 +75,7 @@ async function runPodInstall(loader, options) {
 async function runPodUpdate(loader) {
   try {
     loader.start(`Updating CocoaPods repositories ${_chalk().default.dim('(this may take a few minutes)')}`);
-    await (0, _execa().default)('pod', ['repo', 'update']);
+    await (0, _execa().default)('bundle', ['exec', 'pod', 'repo', 'update']);
   } catch (error) {
     // "pod" command outputs errors to stdout (at least some of them)
     _cliTools().logger.log(error.stderr || error.stdout);
@@ -125,7 +125,7 @@ async function installPods(loader, options) {
       // Check if "pod" is available and usable. It happens that there are
       // multiple versions of "pod" command and even though it's there, it exits
       // with a failure
-      await (0, _execa().default)('pod', ['--version']);
+      await (0, _execa().default)('bundle', ['exec', 'pod', '--version']);
     } catch (e) {
       loader.info();
       await installCocoaPods(loader);

buschco avatar Jun 15 '25 18:06 buschco