skip to Main Content

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?

Warning and path where multiple podfiles are found

7

Answers


  1. 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.

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

    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.


    Login or Signup to reply.
  2. 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

    # Ruby / CocoaPods
    /ios/Pods/
    /vendor/bundle/
    

    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’.

    Login or Signup to reply.
  3. 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.

    # Ruby / CocoaPods
    /ios/Pods/
    /vendor/bundle/

    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.

    Login or Signup to reply.
  4. The warning message is pointing out that the React-Native CLI found two files called "Podfile":

    1. ios/Podfile
    2. vendor/bundle/ruby/2.7.0/gems/cocoapods-core-1.11.3/lib/cocoapods-core/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" .

    Login or Signup to reply.
  5. I dont know exactly what I did, but I resolved my problem.

    1. I updated MacOS and Xcode
    2. I uninstalled cocoapods from gem gem uninstall cocoapods
    3. I had some error while I was running bundle exec pod install. So I used sudo xcode-select --switch /Applications/Xcode.app
    4. Then sudo xcodebuild -license accept
    5. Then I ran installer 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

    1. npx react-native init testproject --skip-install
    2. cd testproject
    3. yarn install
    4. cd ios
    5. bundle install
    6. bundle exec pod install
    Login or Signup to reply.
  6. brew uninstall cocoapods
    gem install cocoapods
    gem environment | grep 'EXECUTABLE DIRECTORY'
    

    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:

    export PATH="/path/to/your/gem/executable/directory:$PATH"
    

    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.

    Login or Signup to reply.
  7. If you are using the expo project,
    It can be explained as follows.

    app.json

    {
      "name": "ExampleApp",
      "displayName": "example app",
       ...
      "ios": {
          "sourceDir": "ios"
      }
    }
    

    If you are using the react-native project,
    It can be explained as follows.

    react-native.config.js

    module.exports = {
      project: {
        ios: {
          "sourceDir": "ios"
        },
      },
    };
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search