React/RCTDefines.h' file not found (RN0.61)

前端 未结 2 1476
情歌与酒
情歌与酒 2020-12-18 09:49

Performed RN upgrade from RN0.60 to RN0.61. Build failed with iOS, due to the following issue:

/react-native/React/Base/RCTBridgeModule.h:10:9: \'React/RCTDe         


        
相关标签:
2条回答
  • 2020-12-18 10:06

    Here's my solution after spending a full day in digging the reason why,
    .
    .
    .
    .

    TLDR;

    You need to add .podspec to podfile for whichever 3rd party/custom library that complain unable to find React/{whatever.h}


    3rd party Libraries

    If you are using a 3rd party library (Yarn/NPM/etc)

    1. Copy podspec from other 3rd party library (eg, RNDeviceInfo/etc..)

    2. Create own podspec by replacing a few item (s.name, s.source) I actually left others as default but you can modify as per your usage if you want

    s.name         = "NoSupportedLib"
    s.source       = { :git => "https://github.com/react-native-community/NoSupportedLibName.git", :tag => "v#{s.version}" }
    

    You might want to take care the following, because not all your dependency may store under the folder path ios/**/your.m & your.h files

    s.source_files  = "ios/**/*.{h,m}"
    
    1. Add new line to podfile pod 'NoSupportedLib', :path => '../node_modules/NoSupportedLib'

    2. Pod install

    Local Dependencies

    In the case where you have a local dependency, you should do the same as well (instead of adding the .a file into your Xcode's Linked Framework and Libraries.)

    1. Follow the same steps as described on top
    2. At step 2 where you declare the s.source & s.source_files, you shall do the following: (Assumption you are create this custom.podspec at the same custom library path, you would otherwise need to modify the s.source path as your need)
    s.source            = { :http => 'file:' + __dir__ + '/' }
    s.source_files  = "customLib/*.{h,m}"
    
    1. Add new line to podfile
    pod 'customLib', :path => '../localDependency/customLib'
    


    Sub-points

    I tried adding React under my scheme as build target, apparently it does not help. I think for project that is >=RN0.60, we are meant to use autolinking provided by ReactNative? Hence to keep our Xcode's Linked Framework and Libraries clean.

    0 讨论(0)
  • 2020-12-18 10:22

    I've had the same issue a while ago. It was fixed after: product > scheme > edit scheme, go to the build tab and add react as the first target.

    0 讨论(0)
提交回复
热议问题