5

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/RCTDefines.h' file not found

I am aware of this breaking changes. (React.xcodeproj is deprecated)

Try a few things

  1. npx react-native-clean-project & re-setup project
  2. remove Pods/ & pod install
  3. ...running out of idea...

Here's how my podfile looks like.

  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"

  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'ReactCommon/jscallinvoker', :path => '../node_modules/react-native/ReactCommon'
  pod 'ReactCommon/turbomodule/core', :path => '../node_modules/react-native/ReactCommon'
  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  # Required by RNFirebase
  pod 'Firebase/Core', '~> 6.9.0'
  pod 'RNFirebase', :path => '../node_modules/react-native-firebase/ios'
  pod 'Fabric', '~> 1.10.2'
  pod 'Crashlytics', '~> 3.14.0'

  # FBSDK
  pod 'react-native-fbsdk', :path => '../node_modules/react-native-fbsdk'

  pod 'react-native-netinfo', :path => '../node_modules/@react-native-community/netinfo'
  pod 'react-native-image-picker', :path => '../node_modules/react-native-image-picker'
  pod 'react-native-splash-screen', :path => '../node_modules/react-native-splash-screen'
  pod 'react-native-webview', :path => '../node_modules/react-native-webview'

4 Answers 4

7

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. enter image description here

11
  • None of the above is working for react-native-local-auth. I created the .podspec inside the ../node_modules/reat-native-local-auth/RNLocalAuth.podspec as you suggested but I get error ---> No podspec found for RNLocalAuth in ../node_modules/react-native-local-auth/RNLocalAuth.podspec
    – Krishna
    Mar 30, 2020 at 11:08
  • @Krishna check again your podspec name and location, you might have pointed it wrongly. Just my guess, you might want to call is this way in your podfile pod 'RNLocalAuth', :path => '../node_modules/react-native-local-auth' Mar 30, 2020 at 14:42
  • Where to copy that podspec file? In main project or in the lib, in which I am getting error? Jan 21, 2021 at 14:40
  • @NarendraSingh As I've mentioned above "Copy podspec from other 3rd party library (eg, RNDeviceInfo/etc..)". Simply just pick one Pod library from your project, look for their .podspec file and make modification to it. Jan 22, 2021 at 1:49
  • but where to paste it? @TommyLeong Jan 22, 2021 at 13:10
0

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.

enter image description here

4
  • 1
    Your answer looks valid but I still face the same output after adding React as my target. I also tried cleaning my build, pods and re-pod install again. Oct 14, 2019 at 10:18
  • Can I check with you if you have any framework / .a files under Linked Framework and Libraries? Oct 14, 2019 at 10:27
  • The only interesting framework I have there is JavascriptScore.framework. Oct 14, 2019 at 10:51
  • Kevin, thanks for your help! I found my answer to solve the issue. Maybe you can take a look and provide your input too :) Oct 15, 2019 at 16:25
0

I had this same issue, I went into /node_modules/react-native/React/Base/RCTBridgeModule.h and changed #import <React/RCTDefines.h> into

#if __has_include("RCTDefines.h")
  #import "RCTDefines.h"
#else
 #import <React/RCTDefines.h>
#endif

ref below link

https://github.com/facebook/react-native/issues/26754#issuecomment-539550146

0
  • Go to Project navigator > Libraries > RNFetchBlob.xcodeproj
  • Click on Build Settings and then the first item under "Targets"
  • Scroll down to 'Search Paths' -> 'Header Search Paths'
  • Make sure to have enable filter 'All'
  • Add the following entry (click '+'): ${SRCROOT}/../../../ios/Pods/Headers
  • Make sure to set it to recursive.
  • Clean (cmd + shift + K) and re-build (cmd + B)

Solved here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.