无法使用 Xcode (React-Native) 将本机包添加到分离的 Expo 项目

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

我正在尝试将本机依赖项添加到一个空白的 Expo 项目中以用于 react-native。在 Xcode: ‘React/RCTBridge.h’ file not found 中构建后,我不断收到此错误。我想使用的特定库是 react-native-camera,但我尝试了其他库,它们也没有正确地 link。我可以使用 react-native-initcreate-react-native-app(已分离)创建的项目正确地将库获取到 link。以下是我创建和分离 expo 项目所采取的步骤:

编辑(我针对不同类型的 linking 执行了不同的步骤 4、5 和 8)

  1. 我创建了一个新的 exp 项目。
  2. 我在 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

我尝试了以下解决方案(A、B、C):

一个。来自:react-native-camera's docs 1) 大部分使用 CocoaPods 自动安装 2)手动安装

乙。来自 : 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

这样做:

C。最后,我试过了

$(SRCROOT) 指的是本机模块的源文件夹,而不是整个项目的顶级根。

我不得不根据我要引入的本机模块的位置(在 node_modules 下)使用 $(SRCROOT)/../../../ios/Pods/Headers/Public。