react-native ios Podfile issue with "use_native_modules!"

If you are using

pod install --project-directory=ios

you might need to tweak the Podfile by replacing

use_native_modules!

to

use_native_modules!(".")

Maybe this behavior will be improved in the future, I opened an issue about it https://github.com/react-native-community/cli/issues/657


Downgraded @react-native-community/cli-platform-ios from 3.1.0 to 3.0.0 and it worked.

Added

"@react-native-community/cli-platform-ios": "3.0.0"

to package.json.

Run npm install and then pod install to get it working again.


Here is the correct answer:

1 - Your POD File 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!