Search code examples
react-nativexcode8detachexpo

Can't add native packages to detached Expo project with Xcode (React-Native)


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 [email protected] --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


Solution

  • $(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).