55

App ran fine on React Native 0.35.0. After updating to 0.40.0 via react-native-git-upgrade I get a number of lexical/preprocessor issues when trying to build/run the app in XCode.

React/RCTBridgeModule.h' file not found

When clicking on the issue I see this highlighted:

#import <React/RCTBridgeModule.h>

It doesn't appear to be a search path issue.

I've tried deleting node_modules and running npm install again, but that hasn't fixed anything.

Robert Schillinger
  • 1,053
  • 3
  • 10
  • 15

10 Answers10

121

As pointed out by th0th, there is a breaking change in RN 0.40 for iOS. In short, RN header declarations are updated to point to the include path $(BUILT_PRODUCTS_DIR)/include/React.

To solve the issue, you have to do the following:

  1. In Xcode, go to the project scheme (Product -> Scheme -> Manage Scheme -> double click your project).
  2. Click on the 'Build' option at the left pane.
  3. Uncheck 'Parallelize Build' under Build Options.
  4. Then in Targets section, click '+' button then search for 'React'. Select it and click 'Add'.
  5. 'React' should now appear under Targets section. Click and drag it to the top so that it will be the first item in the list (before your project).
  6. Clean the project and build.

Note: You might still have similar header issue with other libraries (e.g. react-native-fbsdk) that are referring to those react native .h files.

max23_
  • 6,531
  • 4
  • 22
  • 36
  • 1
    Ah, this took care of the file not found issue. Getting Semantic Issues in the RNFS library now. `Property has a previous declaration` in the RCTBridge.h file. – Robert Schillinger Jan 05 '17 at 15:43
  • 1
    I did a quick check on RNFS library and one of the files, RNFSManager.m appears to import from the old path. You need to change from `#import "RCTBridge.h"` to `#import `. Do the same for `#import "RCTEventDispatcher.h"` too. I think there are a few more .h or .m files that need to be changed as well. – max23_ Jan 05 '17 at 15:48
  • Awesome, this also worked for me. @max23_ , since this is a one-time fix, maybe include a 7th step to reverse those changes (remove 'React' from targets and check parallelize build) – Southerneer Jan 19 '17 at 22:29
  • 1
    @peterept Would you mind share a screenshot of what is still not working? The above solution will only fix RN headers issue resulting from upgrading to RN >=0.40. Possibly your issue is still unresolved due to other libraries which refer to the old path of the RN headers. – max23_ Feb 28 '17 at 12:11
  • 1
    This worked for me when I first upgraded to RN 0.40. Then it started happening again quite a while later. I unchecked 'Parallelize Build' and it started working again... – Paul Hoenecke Mar 01 '17 at 02:51
  • I had misread it originally and checked it... unchecking worked this time. – Paul Hoenecke Mar 01 '17 at 03:12
  • crazy that you had to do this to make it build. thanks...such nuance, wouldve taken me even more hours if i dint find this. – Tope Apr 12 '17 at 20:31
  • 4
    in target section, I am not finding 'react' only. – Prasanna Apr 24 '17 at 14:02
  • i am using 0.43.3 – Prasanna Apr 24 '17 at 14:03
  • 7
    Couldn't find react under targets is that mean react is missing from the project – Muhammad Jul 10 '17 at 16:16
  • 1
    @Muhammad Probably. In Xcode, click "Show the Project navigator" folder icon of the left pane. Expand "Libraries" and look for "React.xcodeproj". If it is highlighted in red, it means React project is missing thus does not show under Build > Targets. – max23_ Jul 10 '17 at 16:44
  • not working for me. Error showing in react-native-audio-streamer module.Please help me. – rajeshpanwar Nov 09 '17 at 07:37
  • "Note: You might still have similar header issue with other libraries (e.g. react-native-fbsdk) that are referring to those react native .h files." That is the exact issue I am having now, any idea on how to fix this? – John Verrone Jan 19 '18 at 17:02
  • 1
    @JohnVerrone It depends which library you are using. The frequently maintained one most likely had already fixed this and you just need to update to a newer version. – max23_ Jan 25 '18 at 16:28
  • _Then in Targets section_ What target section are ypu talking about? – Green Jul 11 '18 at 16:36
  • After installing `react-native-navigation` I'm having a similar issue with `React/RCTConvert.h` and this answer didn't work – Egidio Caprino Nov 14 '18 at 14:18
  • 11
    After upgrading, I'm convinced Facebook should stop all new development and focus solely on fixing their upgrade process, and resume only when it's really fixed. It's been three days of googling and stack overflow. I think I'm on attempt 17 now. Frustrating. – Eddie Eddie Eddie Dec 15 '18 at 20:27
  • 1
    React is grayed out – Nathan B May 21 '19 at 12:00
6

In react-native 0.40


you have to replace #import "RCTBridgeModule.h" with #import <React/RCTBridgeModule.h>

then clean and build it again.

Ashok R
  • 19,892
  • 8
  • 68
  • 68
3

There is a breaking change on 0.40, you can see details here.

Quoting directly from the release notes:

This means that all iOS native libraries need a major version bump for RN 0.40. We attempt to minimize changes of this magnitude, and we apologize for any inconvenience caused.

So, all native iOS libraries will need an update before getting compatible with react-native version 0.40.

Gokhan Sari
  • 7,185
  • 5
  • 34
  • 32
  • Just to be clear (and for my edification) -- does this mean I have to wait for an update from elsewhere? There's no workaround at this time? – Robert Schillinger Jan 05 '17 at 14:48
3

I had the same issue. I have solved it by removing the Test target of my app from build scheme.

2

If your app isn't to large, just

1) rename original app
2) create the same app again react-native init <orig_app_name>
3) copy over all necessary files from your original app to the newly created one
4) adjust the package.json
5) npm install
6) react-native run-<ios|android>

I spent hours to find, where to link the new libraries, it was at least a valuable option and shortcut for me.

hope it helps somebody

radosch
  • 603
  • 7
  • 19
2

If you use pod, maybe you can try this solution:

Go to Header Search Paths: Pods -> TARGETS -> (YOUR TARGET, like my target is RNGL) -> Build Settings -> All -> Search Paths -> Header Search Paths

add a path: "${PODS_ROOT}/Headers/Public/React" non-recursive

1

This steps helped solve my issue. I tried "Uncheck parallelize build" steps. It did not work for me.

  1. Open up your project in XCode.
  2. Open up the Libraries folder. You should see React.xcodeproj and several RCT*.xcodeproj.
  3. Drag the React.xcodeproj into each of the other projects.
  4. Click on each project and navigate to the Build Phases tab.
  5. Click on Target Dependencies and add React as a target dependency
0

Here is how I made it work:

  • I cleaned my package.json to the latest version,
  • I did the trick by @max23_
  • I replaced all the #import '....h' that were causing error to the corresponding #import <React/.....h>.
jrbedard
  • 3,662
  • 5
  • 30
  • 34
0

Update from

import "RCT/BridgeModule.h"

to

import "React/RCT/BridgeModule.h"

the clean and build.

Although, I have not tested it, I suspect if I made no changes and just clean and build it would have done the trick.

Community
  • 1
  • 1
RedEarth
  • 147
  • 1
  • 2
0

Changing the path from:

#import <React/RCTBridgeModule.h>

to:

#import <React/Base/RCTBridgeModule.h>

worked for me.