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

标签 react-native xcode8 detach expo

我正在尝试将 native 依赖项添加到 react native 的空白 Expo 项目中。在 Xcode 中构建后,我不断收到此错误:‘React/RCTBridge.h’ file not found 。我想使用的特定库是 react-native-camera ,但我尝试过其他库,但它们也无法正确链接。我可以让库与使用 react-native-init 创建的项目正确链接和create-react-native-app (已分离)。以下是我创建和分离 expo 项目所采取的步骤:

编辑(对于不同类型的链接,我执行了不同的步骤 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 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0b796e6a687f26656a7f627d6e26686a666e796a4b3b253d" rel="noreferrer noopener nofollow">[email protected]</a> --save

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

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

A.来自:react-native-camera's docs 1) 大多数情况下使用 CocoaPods 自动安装 2)手动安装

B.来自: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

通过这样做: enter image description here

C.最后,我尝试了 This answer from stackoverflow

最佳答案

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

我必须根据我引入的 native 模块的位置(在node_modules下)使用$(SRCROOT)/../../../ios/Pods/Headers/Public。

关于react-native - 无法使用 Xcode (React-Native) 将 native 包添加到分离的 Expo 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45115008/

相关文章:

javascript - undefined 不是函数(计算 '_this._registerEvents()' )

ios - 如何在资源为 5mb 时减小巨大的 .ipa 文件大小

c++ - 自终止线程。使用连接或分离

javascript - 使用 React-Native 拍照、保存并访问相机

firebase - 将 firestore onSnapShot 与 react redux 一起使用的正确方法

javascript - 在 React Native 中创建一个可拖动、可调整大小的框

swift3 - Swift 3 中删除了 preferredStatusBarStyle 吗?

ios - 词法或预处理器问题。 - "File not found."

android - 如何检测 NFC 标签被移除