2

I am trying to add native dependencies to a blank Expo project for react-native. I keep getting this error after the build in Xcode: ‘React/RCTBridge.h’ file not found. The particular library I want to use is react-native-camera, but I have tried other libraries and they don't link correctly either. I can get the libraries to link correctly with projects created with react-native-init and create-react-native-app (which has been detached). Here are the steps I took to create and detach from the expo project:

EDIT (I did steps 4,5, and 8 differently for different types of linking)

  1. I created a new exp project.
  2. I added the following to my app.json: "ios": { "bundleIdentifier": "com.yourcompany.yourappname", "supportsTablet": true }, "android": { "package": "com.yourcompany.yourappname" }
  3. exp detach

  4. npm i react-native-camera@0.6 --save

  5. react-native link
  6. npm i
  7. cd ios
  8. pod install
  9. exp start

I have attempted the following solutions (A, B, C):

A. From: react-native-camera's docs 1)Mostly automatic install with CocoaPods 2)Manual install

B. From : the expo docs

because react-native link is not aware of CocoaPods, it may not do a complete job installing your dependency. If you encounter build issues locating the headers, you may need to manually add Pods/Headers/Public to the Header Search Paths configuration for your native dependency in Xcode...The target you care to configure is the one created by react-native link inside your Xcode project. You’ll want to determine the relative path from your library to Pods/Headers/Public

By doing this: enter image description here

C. And, finally, I tried This answer from stackoverflow

whs.bsmith
  • 386
  • 1
  • 2
  • 12

1 Answers1

2

$(SRCROOT) refers to the native module's source folder rather than the top-level root of the whole project.

I had to use $(SRCROOT)/../../../ios/Pods/Headers/Public based on the location of the native module I ws bringing in (under node_modules).

  • This was a pretty easy fix once I used the correct relative path. The problem is there is so much other information about how to fix this problem (the other steps I tried above) that really have nothing to do with the problem in Expo. Thank @ Kelvin Lawson – whs.bsmith Jul 18 '17 at 18:43
  • Actually, I think I applied method C from my initial question to my project, and I think that might have been necessary, too. – whs.bsmith Jul 18 '17 at 19:03
  • The .xcodeproj file (in this case RCTCamera.xcodeproj) does not seem to be in source control, since it resides in `node_modules`. So setup on a new machine or even after a "npm install" can be cumbersome. Do you have a solution for this? – DerJacques Aug 30 '17 at 09:36