[英]'File not found' when integrating React Native with existing project
I'm having problems integrating React Native into my existing iOS project.我在将 React Native 集成到我现有的 iOS 项目中时遇到问题。 When I run the project through Xcode, everything works as expected.当我通过 Xcode 运行项目时,一切正常。 However, when I run the project with through the terminal (using command: npx react-native run-ios), I get an error as follows:但是,当我通过终端运行项目时(使用命令:npx react-native run-ios),我收到如下错误:
fatal error: 'React/RCTRootView.h' file not found
#import <React/RCTRootView.h>
It's not just RCTRootView though, it's all react native imports.不过,它不仅仅是 RCTRootView,它都是对原生导入的反应。 The setup is done with npm and cocoapods.使用 npm 和 cocoapods 完成设置。 If I remove all the import statements in the code, I instead get this error:如果我删除代码中的所有导入语句,则会收到此错误:
framework not found CoreModules
Steps I've taken:我采取的步骤:
The fact that it all works when running through Xcode was quite confusing.通过 Xcode 运行时一切正常,这一事实非常令人困惑。 I run the same configuration and scheme when running through npx.通过 npx 运行时,我运行相同的配置和方案。
I found the answer halfway through writing the question, so I thought I might as well post it in case it might save someone some time in the future.我在写问题的过程中找到了答案,所以我想我不妨把它贴出来,以防将来可能会节省一些时间。 It took me a while because the initial error I got wasn't the core problem.我花了一段时间,因为我得到的最初错误不是核心问题。
The issue was caused by the fact that I'd forgotten to update the deployment target in the target deployment info (from iOS 9 to iOS 11).问题是由于我忘记更新目标部署信息中的部署目标(从 iOS 9 到 iOS 11)。
Also some cred to where I found the solution:还有一些信任我找到解决方案的地方:
https://github.com/facebook/react-native/issues/26106#issuecomment-600328194 https://github.com/facebook/react-native/issues/26106#issuecomment-600328194
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.