19

I tried to create new React Native project and it failed due to error of multiple podfiles were found.

error: warn Multiple Podfiles were found: ios/Podfile,vendor/bundle/ruby/2.7.0/gems/cocoapods-core-1.11.3/lib/cocoapods-core/Podfile. Choosing ios/Podfile automatically. If you would like to select a different one, you can configure it via "project.ios.sourceDir". You can learn more about it here: https://github.com/react-native-community/cli/blob/master/docs/configuration.md
3
  • 1
    I am getting the exact same error while creating a new project. Commented Oct 21, 2022 at 2:35
  • Specifically React Native 0.70 Commented Oct 21, 2022 at 7:34
  • Did you find a fix for this. It's driving me crazy!
    – Ilir
    Commented Nov 23, 2022 at 2:21

5 Answers 5

16

Create a file called react-native.config.js at the root level of your project with the following contents:

module.exports = {
    project: {
        ios: {
            sourceDir: './ios',
        },
    },
};

Then when you run npx react-native run-ios the Podfile in the ios/ directory will by chosen and you won't see the error.

1
13

Maybe this is just me but this was my experience and fix:

First when I ran xcode-select -p it was returning /Library/Developer/CommandLineTools

However this looked odd as another an answer here seemed to suggest that maybe this was causing an issue. It ended up that I just hadn't set my CLI tools correctly as described in the react native docs. Since it only had one option in the dropdown I assumed that the CLI tools were already set. However when I went back and specifically clicked on the one option, it made changes to my system.

Now running xcode-select -p returns

/Application/Xcode.app/Contents/Developer

TL;DR : Open Xcode, go to 'Settings...' in the menu bar. Then go to the 'Locations' tab and click on the 'Command Line Tools' dropdown and click on the latest version (click on a version even if it seems like a version is already set). Now try your pod install again!

1
  • It worked for me. It seems that command line tools is downloaded, listed on xcode but not selected. After selecting it, pod install succeeded. Commented Dec 26, 2022 at 15:07
4

Same here, below some more details to help solving issue. Fresh new Macbook Pro (M1 Pro) and after following installation steps from rn docs. Same error when init newest version, also same with 0.69.0 npx react-native init AwesomeProject:

✖ Installing CocoaPods dependencies (this may take a few minutes)
error warn Multiple Podfiles were found: ios/Podfile,vendor/bundle/ruby/2.7.0/gems/cocoapods-core-1.11.3/lib/cocoapods-core/Podfile. Choosing ios/Podfile automatically. If you would like to select a different one, you can configure it via "project.ios.sourceDir". You can learn more about it here: https://github.com/react-native-community/cli/blob/master/docs/configuration.md

✖ Installing CocoaPods dependencies (this may take a few minutes)
error 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.

.zshrc

export PATH=/opt/homebrew/bin:$PATH
eval "$(rbenv init - zsh)

"

.zprofile

eval "$(/opt/homebrew/bin/brew shellenv)"
export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools

xcode 14

After

 ruby --version
 brew info cocoapods

i get:

    ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [arm64-darwin21]
    /opt/homebrew/Cellar/cocoapods/1.11.3

I don't understand why its creating new folder with ruby cocoapods inside my rn project: /vendor Never had that issue on my older M1. I already tried with sudo arch -x86_64 gem install ffi

EDIT 1: pod install --project-directory=ios shows me error similar to another cocoaPods issue but didnt fix

Answer in that issue helped. Try:

sudo xcode-select --switch /Applications/Xcode.app

It fixed my errors and allowed me to build 0.70.3 rn init. But before that i've also downgrade my xcode to 13.4, not sure if it was necessary.

But still i get this strange /vendor folder in my rn app, but after deleting it its still building fine on ios.

1

Make sure you enabled command line tools in Xcode. Xcode → settings → Locations → Command line tools

enter image description here

1
  • Hi @Sreedevi, I did but still same error. :) Commented Dec 19, 2022 at 7:56
0

can you try - pod install --project-directory=ios

1
  • it happens at the initial create react native app and it crash before every folders and files created Commented Oct 26, 2022 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.