React Native / Xcode Upgrade and now RCTConvert.h not found

XcodeReactjsReact Native

Xcode Problem Overview


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.

Xcode Solutions


Solution 1 - Xcode

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.

Solution 2 - Xcode


> In react-native 0.40


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

then clean and build it again.

Solution 3 - Xcode

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.

Solution 4 - Xcode

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

Solution 5 - Xcode

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

Solution 6 - Xcode

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

Solution 7 - Xcode

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

Solution 8 - Xcode

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>.

Solution 9 - Xcode

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.

Solution 10 - Xcode

Changing the path from:

#import <React/RCTBridgeModule.h>

to:

#import <React/Base/RCTBridgeModule.h>

worked for me.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRobert SchillingerView Question on Stackoverflow
Solution 1 - Xcodemax23_View Answer on Stackoverflow
Solution 2 - XcodeAshok RView Answer on Stackoverflow
Solution 3 - XcodeGokhan SariView Answer on Stackoverflow
Solution 4 - XcodeSylvia-Kathrin TannebergerView Answer on Stackoverflow
Solution 5 - XcoderadoschView Answer on Stackoverflow
Solution 6 - XcodeXiely_ViomiView Answer on Stackoverflow
Solution 7 - XcodeNiranjan MolkeriView Answer on Stackoverflow
Solution 8 - XcodeRomain AymardView Answer on Stackoverflow
Solution 9 - XcodeRedEarthView Answer on Stackoverflow
Solution 10 - XcodeAlexander KolnogorovView Answer on Stackoverflow