Alex Smith
Alex Smith

Reputation: 151

React Native Xcode header files not being found! RCTBridgeModule

I'm getting 'Lexical or Preprocessor' issues when I try and run on ios either in Xcode or command line. Android builds fine.

The first error is 'React/RCTBridgeModule.h' file not found. I can get rid of this by changing <React/RCTBridgeModule.h> to "RCTBridgeModule.h" but I just end up in an endless stream of the same issue with every module.

I don't believe this is a duplicate question. I've tried all solutions in similar questions and github issues but still can't get it to build;

please check the image for paths

react-native info:

Environment:
  OS: macOS High Sierra 10.13.6
  Node: 8.11.1
  Yarn: 1.12.3
  npm: 6.5.0
  Watchman: 4.9.0
  Xcode: Xcode 10.1 Build version 10B61
  Android Studio: 3.2 AI-181.5540.7.32.5056338

Packages: (wanted => installed)
  react: 16.0.0 => 16.0.0
  react-native: 0.50.4 => 0.50.4

Upvotes: 3

Views: 8209

Answers (2)

Alex Smith
Alex Smith

Reputation: 151

After trying on a different Mac and having the same issue I finally solved this with the following:

  • Uninstall Xcode
  • Install Xcode 9.0 from Apple Developer downloads
  • rm -rf node_modules && yarn cache clean && yarn
  • rm -rf App.xcworkspace Podfile.lock && pod install
  • react-native start --reset-cache
  • Run in Xcode

Here are my new react-native info results:

Environment:
  OS: macOS 10.14.1
  Node: 11.5.0
  Yarn: 1.12.3
  npm: 6.4.1
  Watchman: 4.9.0
  Xcode: Xcode 9.0 Build version 9A235
  Android Studio: 3.2 AI-181.5540.7.32.5056338

Packages: (wanted => installed)
  react: 16.0.0 => 16.0.0
  react-native: 0.50.4 => 0.50.4

Upvotes: 0

Rizwan Atta
Rizwan Atta

Reputation: 3295

my solution a bit dangerous sometimes!

in old days this happened when I was trying to archive a 0.40+ react-native app for iOS (i found a solution here https://github.com/facebook/react-native/issues/11721#issuecomment-270672904)

i felt like Xcode was trying to build the react-native libraries in parallel with implicit react dependencies before actually building the react library.

so this helped a little !

  • In Xcode, go to the project scheme (Product -> Scheme -> Manage Scheme -> double click your project).

  • Click on the 'Build' option at the left pane.

  • Uncheck 'Parallelize Build' under Build Options.

  • Then in Targets section, click '+' button then search for 'React'. Select it and click 'Add'. '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).

  • Clean the project and build.

there are a few more trivial solutions for this scenario that i found are enlisted on another stackQuestion here

Upvotes: 6

Related Questions