Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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'
like image 233
TommyLeong Avatar asked Oct 14 '19 09:10

TommyLeong


1 Answers

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

like image 179
TommyLeong Avatar answered Nov 15 '22 08:11

TommyLeong