【问题标题】:React Native ios build error 'React/RCTBridgeModule.h' file not found with react-native-document-picker使用 react-native-document-picker 找不到 React Native ios 构建错误“React/RCTBridgeModule.h”文件
【发布时间】:2021-04-18 03:21:49
【问题描述】:

由于该问题,我无法构建 iOS 应用程序 - 'React/RCTBridgeModule.h' 文件未找到

"react": "^16.13.1", 
"react-native": "^0.63.4", 
"react-native-document-picker": "^4.2.0"

iOS 目标 -- 10.0

我已经尝试了一些建议的解决方案,包括 this。但是,无法执行以下步骤,因为没有可用的 React.xcodeproj 文件

将 react 添加为项目依赖项

Xcode Project Navigator -> 将 React.xcodeproj 从 Libraries 拖到根目录 tree Build Phases Tab -> Target Dependencies -> + -> add React

也试过了 https://stackoverflow.com/a/52425997/1479511 和 https://stackoverflow.com/a/41664041/1479511

但仍然没有运气:(

更新

尝试按照@Muhammad Numan 在答案中建议的步骤进行操作。

  1. 检查我的 pod 中是否有 React(pod 'React', :path => '../node_modules/react-native/')。如果没有,请添加它。
  2. 卸载重新安装 pod(pod deintegrate && pod clean && pod 安装在ios文件夹中,我相信pod deintegrate命令 需要下载,默认不可用)

所以,React.podspec 的修改内容来自

s.dependency "React-Core", version
  s.dependency "React-Core/DevSupport", version
  s.dependency "React-Core/RCTWebSocket", version
  s.dependency "React-RCTActionSheet", version
  s.dependency "React-RCTAnimation", version
  s.dependency "React-RCTBlob", version
  s.dependency "React-RCTImage", version
  s.dependency "React-RCTLinking", version
  s.dependency "React-RCTNetwork", version
  s.dependency "React-RCTSettings", version
  s.dependency "React-RCTText", version
  s.dependency "React-RCTVibration", version

到

s.dependency "React/Core", version
  s.dependency "React/Core/DevSupport", version
  s.dependency "React/Core/RCTWebSocket", version
  s.dependency "React/RCTActionSheet", version
  s.dependency "React/RCTAnimation", version
  s.dependency "React/RCTBlob", version
  s.dependency "React/RCTImage", version
  s.dependency "React/RCTLinking", version
  s.dependency "React/RCTNetwork", version
  s.dependency "React/RCTSettings", version
  s.dependency "React/RCTText", version
  s.dependency "React/RCTVibration", version

后跟命令pod repo update

然后,然后,得到这个错误

【问题讨论】:

  • 请尝试删除 pods 文件夹和 podfile.lock 并尝试运行 pod update。
  • 与pod update 也出现同样的错误@HGK

标签: ios react-native build-error rctbridge


【解决方案1】:

我认为你有反应缺失的东西,这就是我所做的。

  1. 检查我的 pod 中是否有 React(pod 'React', :path => '../node_modules/react-native/')。如果没有,请添加它。
  2. 卸载重装pods(在ios文件夹下pod deintegrate && pod clean && pod install,我认为pod deintegrate命令需要下载,默认不可用)
  3. 转到方案 -> 编辑方案 -> 构建,使用“减号”按钮删除 React(缺失)。单击“添加”或“加号”按钮。找到 React(应该在 Pods 类别中)并添加它。最后,确保为 React 勾选了所有框,并将其放在列表的顶部。

给你,希望对你有帮助。但是,如果您没有 React(缺少),我不知道如何解决这个问题,因为我从来没有遇到过这个问题:/

【讨论】:

  • 我尝试按照您建议的步骤进行操作。但是现在pod install 出现了一些其他错误。请查看我帖子中的UPDATE。
  • @NarendraSingh 你能试试这个命令吗pod repo update
  • 删除 podfile.lock 然后试试这个
  • 还是没有运气:/
【解决方案2】:

我之前用 this solution 修复了这个问题,这实际上是由 React Native 重大更改引起的(不推荐使用 React.xcodeproj)。

由于详细答案在链接的帖子中,我不再在这里重新发布整个解决方案,而只是为您提供一个 TLDR。


TLDR;

对于抱怨找不到 React/{whatever.h} 的任何第 3 方/自定义库,您需要将 .podspec 添加到 podfile 中

【讨论】:

  • @Narendra Singh,我们也在项目中使用react-native-document-picker。但是,我们不在最新版本 4.3.0 上,而是使用 2.1.0。我不确定这些版本之间是否有任何重大变化,但我想你可以在 2.1.0 上试一试,看看它是否也适合你。
  • 降到 2.1.0 之后。我开始收到另一个错误,即'React/RCTDefines.h' file not found
  • 在尝试减少到​​2.1.0 之前,您是否尝试过我在链接中分享的solution?
  • 我试过了,但得到一个错误@TommyLeong
猜你喜欢
  • 2019-08-10
  • 1970-01-01
  • 2021-10-20
  • 2018-10-06
  • 1970-01-01
  • 2018-10-31
  • 2022-11-19
  • 1970-01-01
  • 2016-10-27
相关资源
最近更新 更多