Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Installing CocoaPods dependencies when initiating new React Native project

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
like image 248
Phok Chanrithisak Avatar asked Dec 02 '25 15:12

Phok Chanrithisak


2 Answers

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.

like image 180
par Avatar answered Dec 05 '25 04:12

par


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!

like image 26
SeanDemps Avatar answered Dec 05 '25 05:12

SeanDemps