I am new to react native for iOS. I am using an M1 Mac so Cocoapods was tricky to install. My app runs fine, but now after a recent bundle, I get this warning that multiple podfiles were found for cocoa pods-core. The two podfiles are shown on the left in the image and are different names. Which one is being automatically used and which one can I delete?
Question posted in React native
The official React Native documentation can be found here.
The official React Native documentation can be found here.
7
Answers
From the react-native-community docs:
A project can define a
react-native.config.js
at the root with a custom configuration to be picked up by the CLI.For example, the below configuration informs CLI about a source directory with iOS files.
Note: You may find this useful in scenarios where multiple Podfile files are present and CLI chooses the wrong one. When that happens, CLI will print a warning asking you to verify its selection.
I am using also M1 and upgraded for one of my project React-Native 0.64.4 to 0.69.5. After all setup finished I got also the same warning while trying to get IOS build.
I made some research and understand that vendor folder created by ruby installation and in RN Project we don’t need that folder.
Simply I deleted vendor folder and try to get IOS and Android build. Both is working without vendor folder.
There are some discussions here:
https://www.reddit.com/r/reactnative/comments/taz1k7/vendor_folder_in_new_reactnative_typescript/
But according to React Native Upgrade Helper Doc:
https://react-native-community.github.io/upgrade-helper/?from=0.64.4&to=0.69.5
.gitignore file should be changed like this
Therefore vendor folder can stay in your local and you can get warning while trying to get ios build, but it is not a problem because in your build you will stay using your ‘ios/Podfile’.
Podfile which is in ios folder that is specific to our project so we should never delete it. otherwise you will not be able to run the ios project.
Now if we talk about vendor folder’s podfile we can ignore it. They might be using internally but it will not affected to our project while we do pod install. So keep both files as is.
And in .gitignore file we should add below code.
Even mentioned here. https://react-native-community.github.io/upgrade-helper/?from=0.64.4&to=0.69.5
I hope this is helpful to you. Let me know is it solved your query your not.
The warning message is pointing out that the React-Native CLI found two files called "Podfile":
It also points out that the Podfile inside the ios directory will be used. This directory and file is not shown in your screenshot; the ios directory is likely a sibling to the vendor directory shown in your screenshot.
You should not delete either of the Podfiles. The ios/Podfile is the default one created and used when creating a React-Native project via the React-Native CLI. The other Podfile (nested inside the cocoapods-core gem) is part of the cocoapods gem and is used to build out the CocoaPods libraries.
You can remove the warning by specifying which Podfile the React-Native CLI should use, as @avrahm-kleinholz posted in their answer.
In your case, change "./custom-ios-location" to "./ios" .
I dont know exactly what I did, but I resolved my problem.
gem uninstall cocoapods
bundle exec pod install
. So I usedsudo xcode-select --switch /Applications/Xcode.app
sudo xcodebuild -license accept
npx react-native init template --template react-native-template-typescript
and everything was good!Also I can recommend you to use these commands to know where is your error
npx react-native init testproject --skip-install
cd testproject
yarn install
cd ios
bundle install
bundle exec pod install
This will show you the path to the ‘EXECUTABLE DIRECTORY’, which you should add to your PATH in your ~/.zshrc (or ~/.zprofile) file, like this:
run
source ~/.zshrc (or source ~/.zprofile)
to apply the changes.Run
pod --version
to verify that the gem version of CocoaPods is installed and working correctly.If you are using the
expo
project,It can be explained as follows.
If you are using the
react-native
project,It can be explained as follows.