react-native ios Podfile issue with “use_native_modules!”

前端 未结 18 1909
一生所求
一生所求 2020-12-05 17:15

In my react-native project (react-native@0.60) in the ios/ dir I run pod install and get this error:

[!] Invalid `Podfile` file: no implicit con         


        
相关标签:
18条回答
  • 2020-12-05 17:49

    The issue is that:

    use_native_modules!
    

    is unsupported by earlier versions of CocoaPods. For example, our install was the app downloaded from the CocaoPods website. That version is 1.5.2.

    Run:

    pod --version
    

    to check which version. If need be, uninstall and then re-install but in Terminal by running:

    sudo gem install cocoapods
    

    At least as of late October 2019, the current gem version available is 1.8.4. Once successfully installed, re-attempt the pod install and hopefully all is well.

    0 讨论(0)
  • 2020-12-05 17:50

    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!

    0 讨论(0)
  • 2020-12-05 17:51

    Go to this repository : ProjectName -> ios -> Podfile In Podfile, delete use_native_modules! Execute again pod install And Enjoy your use

    0 讨论(0)
  • 2020-12-05 17:52

    Verify if you have @react-native-community/cli-platform-ios in your package.json,

    if you dont run:

    npm install @react-native-community/cli-platform-ios

    then

    cd ios && pod install

    0 讨论(0)
  • 2020-12-05 17:55

    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.

    0 讨论(0)
  • 2020-12-05 17:56

    Don't use yarn install. Thats what worked for me...

    • Go to main folder
    • Delete nodes folder
    • Run sudo npm install or just npm install
    • cd ios
    • pod install
    0 讨论(0)
提交回复
热议问题