React-native-fs: 'React/RCTBridgeModule.h' file not found after Cocoapods installation

Created on 27 Dec 2017  路  13Comments  路  Source: itinance/react-native-fs

Trying to install with npm on an empty react-native init app and adding the attached
Podfile, results in the following compilation error on Xcode: 'React/RCTBridgeModule.h' file not found on this line: #import <React/RCTBridgeModule.h>.

feedback-wanted help wanted more info needed

Most helpful comment

Two workarounds

  1. Follow @itinance link
  2. Rename/Delete Podfile, link and restore Podfile. This is the way react-native link used to work.

All 13 comments

The error indicates the code depends on React and this should be indicated in RNFS.podspec with the following line: s.dependency 'React'.

@itinance I saw you changed the file very recently. Can you please take a look at the PR?

Hi @tomer1490 !

There was an issue with the "react"-dependency as it causes installations of React in Versionnumber 0.11, which is dead old and leads to multiple compiler issues.

I did several tests and found out that without the dependency everything was working fine.
In your attached Podfile your are already adding React as Pod, are you sure that it has installed the right version?

I used the react-native init starter project with a default new version of React.
EDIT: package.json
react version is 16 and react-native version is 0.51.
I didn't use react-native link. Only added the Podfile and ran pod install.
Xcode version: 9.1, react-native-cli: version 2.0.1.

Xcode needs to be informed in the build process to link React.framework into RNFS in order for the import #import <React/RCTBridgeModule.h> to compile. Specifying s.dependency 'React' tells Cocoapods during pod install to link React to RNFS. The React project will be taken from the Podfile in the root of the project. Usually it will be from the node_modules directory as stated in the Podfile: pod 'React', :path => '../node_modules/react-native' and the version will be decided from package.json.

Can you try creating a new project using react-native init, use the attached Podfile or another if you like, and see if the project compiles for you?

same problem here, any solution?

Hi @7ynk3r ,
Can you try using a fork of the library with my pull request and see if it solves your issue?
In package.json: "react-native-fs": "git://github.com/tomer1490/react-native-fs.git"

Here is more discussion on the topic. The issue with react as dependency is that it will install React 0.11 instead of the current version. There are many things messed up on this.

Btw, the same issue appears on other libraries like Bugsnag: https://github.com/bugsnag/bugsnag-react-native/issues/193
Another Issue on react-native itself for this: https://github.com/facebook/react-native/issues/16912

I hope we'll find a solution that fits both scenarios, those with and those without Cocoapods.

@tomer1490 it doesn't work. i'll try forking and adding react as a local reference in pods.

Try adding in your Podfile: pod 'React', :path => '../node_modules/react-native'. It should tell Cocoapods to use the version of react installed from package.json.

And pls follow these recommendations: https://github.com/bugsnag/bugsnag-react-native/issues/193#issuecomment-355166756

Two workarounds

  1. Follow @itinance link
  2. Rename/Delete Podfile, link and restore Podfile. This is the way react-native link used to work.

Same error.

Installed this module using npm install --save react-native-fs which installed release 2.9.7(though it's not even in the release list which is confusing).

First problem was the one mentioned here
Fixed it by manually setting react-native-fs package to 2.9.6

After cleaning project (rm node_modules, rm ios/Pods, cleaning XCode build etc) I ran into the problem mentioned here.

At this point I spent 2 hours trying to install a package to no avail.

For clarity, the link says:

Add this to your Podfile:

# React Native requirements
pod 'yoga', path: './node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => './node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'Folly', :podspec => './node_modules/react-native/third-party-podspecs/Folly.podspec'
pod 'GLog', :podspec => './node_modules/react-native/third-party-podspecs/GLog.podspec'
pod 'React', path: './node_modules/react-native', subspecs: [
  'Core',
  'jschelpers',
  'cxxreact',
  'CxxBridge',
  'DevSupport',
  'RCTText',
  'RCTImage',
  'RCTNetwork',
  'RCTActionSheet',
  'RCTAnimation',
  'RCTWebSocket',
]

I had to modify this slightly changing GLog to glog. Also, if your node_modules directory is not in the same directory as your Podfile change your paths to ../node_modules

Was this page helpful?
0 / 5 - 0 ratings