简体   繁体   English

将 React Native 与现有项目集成时出现“找不到文件”

[英]'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.

相关问题 集成在React Native上找不到的现有应用程序iOS“React / RCTEventDispatcher.h”文件 - Integrating existing app iOS 'React/RCTEventDispatcher.h' file not found on React Native 将react native集成到现有的Swift项目中:找不到&#39;string&#39;文件 - Integrate react native into existing Swift project: 'string' file not found React-Native与现有应用程序“RCTRootView.h”文件集成未找到 - React-Native Integrating with Existing Apps 'RCTRootView.h' file not found 将 Flutter 模块集成到现有 iOS 项目时找不到“Flutter/Flutter.h”文件 - 'Flutter/Flutter.h' file not found when integrating flutter module to existing iOS project 将React Native集成到现有的iOS和android项目中,而无需修改现有的目录结构 - Integrating react native in existing iOS & android project without modifying existing directory structure 将React-Native集成到现有App - Integrating React-Native to an existing App react-native与现有ios应用程序集成 - react-native integrating with existing ios apps 在我的 kmm 项目中集成 React Native 应用程序 - integrating react native app in my kmm project 将React Native Library集成到现有的本机iOS / Android应用程序中 - Integrating a React Native Library into existing native iOS / Android application 在 React Native 的 iOS 项目中找不到“config.h”文件 - “config.h” file not found in iOS project of React native
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM