react-native ios Podfile issue with “use_native_modules!”

Here is the correct answer:

1 – Your Podfile should contain this line on top

require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

2 – Make sure your package.json and node_module folders has this module installed

cli-platform-ios/native_modules

3 – If you didn’t find after you run yarn install – means you have old cache node_modules in your machine and you need to clean it before reinstalling the package again.

4 – Clean cache yarn cache clean

5 – Make sure you have this file react-native.config.js and its configuration is VALID – and it doesn’t have non-existing NPM packages – this step is LAST AND MOSTLY THE CAUSE of the error

Example of my react-native.config.js

module.exports = {
  project: {
    ios: {},
    android: {},
  },
  assets: ['./assets/fonts/'],
  dependencies: {}, // make sure this dependencies are all valid installed packages or empty if you don't need it
};

6 – Install node packages yarn install and your pods should work now! pod install --repo-update

HAPPY coding!

Leave a Comment