ios 未找到 `React/RCTBridgeModule.h` 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41663002/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
`React/RCTBridgeModule.h` file not found
提问by Simar
Getting this error while building a react-native iOS app on xcode.
在 xcode 上构建 react-native iOS 应用程序时出现此错误。
Started getting this error after npm install and rpm linking react-native-fslibrary. But after searching online for a solution, I noticed that many people are getting the same error while installing other react native libraries.
在 npm install 和 rpm 链接react-native-fs库后开始出现此错误。但是在网上搜索解决方案后,我注意到很多人在安装其他 react native 库时都遇到了同样的错误。
A possible solutionsuggested by many is, Adding the following under "Build Settings" -> "Header Search Paths".
一个可能的解决方案被许多建议,把下面的在“构建设置” - >“头搜索路径”。
$(SRCROOT)/../node_modules/react-native/React
- (Recursive)
$(SRCROOT)/../node_modules/react-native/React
- (递归)
But no luck with this solution, still getting the same error
但是这个解决方案没有运气,仍然得到同样的错误
回答by agiaLab
In my case this particular problem happened when I was trying to archive a 0.40+ react-native app for iOS (solution was found here: Reliable build on ^0.39.2
fails when upgrading to ^0.40.0
).
在我的情况下,当我尝试为 iOS 归档 0.40+ react-native 应用程序时,发生了这个特殊问题(解决方案在这里找到:可靠构建^0.39.2
失败时升级到^0.40.0
)。
What happened was that Xcodewas trying to build the react-native libraries in paralleland was building libraries with implicit react dependencies beforeactually building the react library.
发生的事情是Xcode试图并行构建 react-native 库,并且在实际构建 react 库之前构建具有隐式 react 依赖项的库。
The solution in my case was to:
在我的情况下的解决方案是:
Disable the parallel builds:
- Xcode menu -> Product -> Scheme -> Manage Shemes...
- Double click on your application
- Build tab -> uncheck Parallelize Build
Add react as a project dependecy
- Xcode Project Navigator -> drag React.xcodeproj from Libraries to root tree
- Build Phases Tab -> Target Dependencies -> + -> add React
禁用并行构建:
- Xcode 菜单 -> Product -> Scheme -> Manage Shemes...
- 双击您的应用程序
- 构建选项卡 -> 取消选中并行构建
添加反应作为项目依赖
- Xcode Project Navigator -> 将 React.xcodeproj 从 Libraries 拖到根树
- 构建阶段选项卡 -> 目标依赖 -> + -> 添加React
回答by onmyway133
回答by Simar
QUICK FIX (not the best)
快速修复(不是最好的)
Change the import react-native header lines:
更改导入 react-native 标题行:
#import <React/RCTBridgeModule.h>
#import <React/RCTLog.h>
To:
到:
#import "RCTBridgeModule.h"
#import "RCTLog.h"
Here is an example of changes I had to make for the library I was trying to use: Closes #46 - 'RCTBridgeModule.h' file not found.
这是我必须对我尝试使用的库进行更改的示例:Closes #46 - 'RCTBridgeModule.h' file not found。
回答by Mantas Laurinavi?ius
Change
改变
#import "RCTBridgeModule.h"
to
到
#import "React/RCTBridgeModule.h"
回答by lawrence
For viewers who got this error after upgrading React Native to 0.40+, you may need to run react-native upgrade
on the command line.
对于在将 React Native 升级到 0.40+ 后出现此错误的查看器,您可能需要react-native upgrade
在命令行上运行。
回答by Codler
If Libraries/React.xcodeproj
are red in xcode then reinstall node_modules
如果Libraries/React.xcodeproj
在 xcode 中为红色,则重新安装 node_modules
rm -rf node_modules && yarn
My newly created project from react-native 0.46.3 was red :S I have npm 5.3.0 and yarn 0.24.5 when I did react-native init
我从 react-native 0.46.3 新创建的项目是红色的:当我执行 react-native init 时,SI 有 npm 5.3.0 和 yarn 0.24.5
回答by BuffMcBigHuge
I was able to build a debug, but I was unable to build an archive.
我能够构建调试,但无法构建存档。
I solved this issue by dragging React.xcodeproj
found in /node_modules/react-native/React to my root directory in Xcode, then added React as a target dependancy in build phases > target dependencies.
我通过将React.xcodeproj
在 /node_modules/react-native/React 中找到的拖到我的 Xcode 根目录中解决了这个问题,然后在构建阶段 > 目标依赖项中添加了 React 作为目标依赖项。
回答by Max Vorobjev
Latest releases of react-native libraries as explained in previous posts and herehave breaking compatibility changes. If you do not plan to upgrade to react-native 0.40+ yet you can force install previous version of the library, for example with react-native-fs:
最新版本的 react-native 库如之前的帖子中所述,这里有重大的兼容性更改。如果您不打算升级到 react-native 0.40+,但可以强制安装该库的先前版本,例如使用 react-native-fs:
npm install --save -E [email protected]
回答by Peter Theill
After React Native 0.60 this issue is often caused by a linked library mixed with the new 'auto-linking' feature. This fixes it for me
在 React Native 0.60 之后,这个问题通常是由链接库与新的“自动链接”功能混合引起的。这对我来说修复了
Unlink old library using
使用取消链接旧库
$ react-native unlink react-native-fs
Refresh Pods integration entirely using
完全使用刷新 Pods 集成
$ pod deintegrate && pod install
Now reload your workspace and do a clean build.
现在重新加载您的工作区并进行干净的构建。
回答by Taylor Kline
I receive this error in any new module I create with create-react-native-module. None of the posted solutions worked for me.
我在使用create-react-native-module 创建的任何新模块中收到此错误。没有一个已发布的解决方案对我有用。
What worked for me was first making sure to run yarn
in the newly created module folder in order to create node_modules/
(this step is probably obvious). Then, in XCode, select Product -> Scheme -> React instead of the default selection of MyModuleName.
对我有用的是首先确保yarn
在新创建的模块文件夹中运行以便创建node_modules/
(这一步可能很明显)。然后,在 XCode 中,选择 Product -> Scheme -> React 而不是 MyModuleName 的默认选择。