3

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;

  • Unchecked Parallelize Build
  • Ensured imports are using the updated format e.g. #import <React/RCTBridgeModule.h>
  • Removed node_modules, .xcworkspace and podfile.lock and reinstalled/updated using both npm and yarn
  • Tried react-native upgrade
  • React and Pods project are listed above the project in Edit Scheme > Build
  • Tried both Xcode 9 & 10 with both Legacy & New build systems

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
Rizwan Atta
  • 3,222
  • 2
  • 19
  • 31
Alex Smith
  • 151
  • 1
  • 2
  • 7
  • i will recommend upgrading your OS version and XCODE VERSION! and also react native too! – Rizwan Atta Dec 19 '18 at 15:30
  • We have an app in production using these versions, it was working before. Could there be a an issue with Xcode linking files since re-cloning the repo? – Alex Smith Dec 20 '18 at 10:49

2 Answers2

6

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

Rizwan Atta
  • 3,222
  • 2
  • 19
  • 31
0

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
Alex Smith
  • 151
  • 1
  • 2
  • 7