简体   繁体   English

未找到“RCTBundleURLProvider.h”文件 - AppDelegate.m

[英]“RCTBundleURLProvider.h” file not found - AppDelegate.m

I am trying to run my React Native app in XCode and I keep getting this error.我正在尝试在 XCode 中运行我的 React Native 应用程序,但我不断收到此错误。 I cannot figure out how to resolve the issue.我不知道如何解决这个问题。 Any suggestions?有什么建议吗?

Screen Shot of Error in XCode: XCode 中错误的屏幕截图:

截图

xcode Product->Scheme->Manage Schemes 在 Target 处单击“+”以选择“React”并设置 React 是共享的。

Delete node modules, then run npm install (or better yet yarn) and after everything has finished downloading, run react-native upgrade which should give you the option to replace old files with the template ones, by doing so you re-link your native dependencies in react-native which should fix your problem.删除节点模块,然后运行npm install (或更好的 yarn),在所有内容下载完成后,运行react-native upgrade这应该会给你一个用模板替换旧文件的选项,这样做你重新链接你的本地文件react-native 中的依赖项应该可以解决您的问题。 Of course don't forget to clean your project in Xcode.当然不要忘记在 Xcode 中清理你的项目。

For all those are using React Native 0.40.0 or higher, Header Imports have a major change from RN 0.40.0 and result in lots of .h file not found errors.对于所有使用React Native 0.40.0或更高版本的用户,Header Imports 与RN 0.40.0 相比有重大变化,并导致大量 .h 文件未找到错误。 react-native-git-upgrade fixed the issue for me while in debug but build fails in release/archive. react-native-git-upgrade在调试时为我解决了这个问题,但在发布/存档时构建失败。

I am using RN 0.42.3 with cocoapods and Xcode 8.2.1我将RN 0.42.3与 cocoapods 和Xcode 8.2.1 一起使用

To completely fix this go to Xcode>Product>Scheme>Edit Scheme>要完全解决此问题,请转到 Xcode>Product>Scheme>Edit Scheme>

  1. Untick Parallelize Build取消并行化构建在此处输入图片说明
  2. Click on + button in Targets and add React单击 Targets 中的 + 按钮并添加React 在此处输入图片说明
  3. Drag the added React to top of the List in Targets.将添加的React 拖到Targets 中的列表顶部。 在此处输入图片说明

Now clean the project and build现在清理项目并构建

None of the other suggestions were fixing my error but this one did it.其他建议都没有解决我的错误,但这个建议做到了。

1 - Create Podfile 1 - 创建 Podfile

Create a file named ios/Podfile inside your react-native app with the following contents:在您的 react-native 应用程序中创建一个名为ios/Podfile的文件,其中包含以下内容:

# You Podfile should look similar to this file. React Native currently does not support use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '8.0'

target '<YOUR_APP_NAME>' do
  # Fixes required for pod specs to work with rn 0.42
  react_native_path = "../node_modules/react-native"
  pod "Yoga", :path => "#{react_native_path}/ReactCommon/yoga"
  pod "React", :path => react_native_path, :subspecs => [
    'Core',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket'
  ]

  pod 'GoogleMaps'  # <~~ remove this line if you do not want to support GoogleMaps on iOS

# when not using frameworks  we can do this instead of including the source files in our project (1/4):
#  pod 'react-native-maps', path: '../../'
#  pod 'react-native-google-maps', path: '../../'  # <~~ if you need GoogleMaps support on iOS
end

2 - Install Podfile 2 - 安装 Podfile

Run the command pod install from inside the ios folder.从 ios 文件夹中运行命令pod install

3 - Reset XCode 3 - 重置 XCode

Restart XCode and the error should be gone.重新启动 XCode,错误应该消失了。

The solution that works for me is to share React scheme.对我React的解决方案是共享React方案。

If you don't have React scheme, create new one by Selecting scheme menu -> Manage Scheme -> + -> choose React , then mark React scheme as Shared如果您没有 React 方案,请通过Selecting scheme menu -> Manage Scheme -> + -> choose React创建新Selecting scheme menu -> Manage Scheme -> + -> choose React ,然后将 React 方案标记为 Shared

在此处输入图片说明

在此处输入图片说明 在此处输入图片说明

Also, if you use Xcode 10, go to File -> Project Settings and select Legacy build system此外,如果您使用 Xcode 10,请转到File -> Project Settings并选择 Legacy build system

在此处输入图片说明

I ran into this problem after my first try running a React build in XCode, and all I had to do was actually build and run to make the error go away (after picking a team and proper provisioning).在我第一次尝试在 XCode 中运行 React 构建后,我遇到了这个问题,我所要做的就是实际构建并运行以消除错误(在选择团队并正确配置之后)。 Sometimes XCode shows errors that aren't really errors until it compiles and links things the first time.有时 XCode 显示的错误在它第一次编译和链接之前并不是真正的错误。

I solved this problem by following steps:我通过以下步骤解决了这个问题:

  1. In xcode choose project root.在 xcode 中选择项目根目录。
  2. Drag React.xcodeproj from Libraries to the root of the project.React.xcodeprojLibraries React.xcodeproj项目的根目录。
  3. Click on project name (in my case it name SaleKit ) in TARGETS单击TARGETS项目名称(在我的例子中它命名为SaleKit
  4. Choose Build Phases选择Build Phases
  5. In dropdown of Target Dependencies add ReactTarget Dependencies项的下拉列表中添加React
  6. Rebuild or re-run重建或重新运行

在此处输入图片说明

For my case in ReactNative "0.54.2", i solved it with following solution对于我在 ReactNative "0.54.2" 中的情况,我用以下解决方案解决了它

In Xcode select Product->Scheme->Manage Schemes , untick 'YourProject'-tvOS set it to not Shared在 Xcode 中选择Product->Scheme->Manage Schemes ,取消Product->Scheme->Manage Schemes 'YourProject'-tvOS 将其设置为不共享

Best Solution :最佳解决方案:

Open 'Build Settings' for your project in Xcode , search 'Header Search Path'.在 Xcode 中为您的项目打开“Build Settings”,搜索“Header Search Path”。

Double click next to 'Header Search Path', where other properties have a 'yes' or 'no'双击“标题搜索路径”旁边的其他属性有“是”或“否”

Now add following to the "Header Search Path" (under Build Settings):现在将以下内容添加到“标题搜索路径”(在构建设置下):

$(SRCROOT)/../node_modules/react-native/React
$(SRCROOT)/../node_modules/react-native/React/Base

Don`t forget Make both of them recursive.不要忘记使它们都递归。

You might be running .xcodeproj file after pod is installed.安装 pod 后,您可能正在运行.xcodeproj文件。

Close it and open .xcworkspace file.关闭它并打开.xcworkspace文件。 It worked for me.它对我有用。

In the base dir of the project I run:在我运行的项目的基本目录中:

node_modules/react-native/packager/packager.sh --reset-cache

Which resulted in:这导致:

Scanning 554 folders for symlinks in /Users/..../work/..../react_tutorial/AwesomeProject/node_modules (15ms)
 ┌────────────────────────────────────────────────────────────────────────────┐
 │  Running packager on port 8081.                                            │
 │                                                                            │
 │  Keep this packager running while developing on any JS projects. Feel      │
 │  free to close this tab and run your own packager instance if you          │
 │  prefer.                                                                   │
 │                                                                            │
 │  https://github.com/facebook/react-native                                  │
 │                                                                            │
 └────────────────────────────────────────────────────────────────────────────┘
Looking for JS files in
   /Users/..../work/...../react_tutorial/AwesomeProject

Loading dependency graph... ERROR  Packager can't listen on port 8081
Most likely another process is already using this port
Run the following command to find out which process:

lsof -i :8081

I found that package manager can't run when another packager process is running.我发现当另一个打包进程正在运行时,包管理器无法运行。

I found the process running with:我发现该进程正在运行:

lsof -i :8081

Than I kill 9 ... the process.比我kill 9 ...的过程。

After than I closed Xcode, run:在我关闭 Xcode 之后,运行:

npm install

And started Xcode again, from this moment everything work as expected!!并再次启动 Xcode,从这一刻起一切都按预期工作!!

Try the following:请尝试以下操作:

  1. Clean ( cmd + shift + K ).清洁( cmd + shift + K )。
  2. Build core React - select React as the scheme in Xcode and build it ( cmd + B ).构建核心 React - 在 Xcode 中选择 React 作为方案并构建它( cmd + B )。
  3. Build the library that is failing (eg RCTText).构建失败的库(例如 RCTText)。
  4. Build your app.构建您的应用程序。

I had the same issue and I fixed it by placing RNFIRMessaging.h above the React/RCTBundleURLProvider.h我遇到了同样的问题,我通过将RNFIRMessaging.h放在React/RCTBundleURLProvider.h 之上来解决它

So it look I will look like:所以看起来我看起来像:

#import "AppDelegate.h"
#import "RNFIRMessaging.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

在您的项目目录中运行npm install以安装react-native解决此错误。

click Product->Scheme->Manage Schemes->+ .点击产品->方案->管理方案->+。 and then add react as shared.然后添加反应作为共享。 also insure that your project name is there too.还要确保您的项目名称也在那里。

I faced same issue .then i have deleted node .try to use these steps我遇到了同样的问题。然后我删除了节点。尝试使用这些步骤

  1. Delete the node_modules folder - rm -rf node_modules && npm install删除 node_modules 文件夹 - rm -rf node_modules && npm install
  2. Reset packager cache - rm -fr $TMPDIR/react-* or node_modules/react-native/packager/packager.sh --reset-cache重置打包缓存 - rm -fr $TMPDIR/react-* 或 node_modules/react-native/packager/packager.sh --reset-cache
  3. Clear watchman watches - watchman watch-del-all清除守望者手表 - watchman watch-del-all

then make build and see然后进行构建并查看

我发现升级 React 后我解决这个问题的方法是将#import "RCTBundleURLProvider.h"的声明更改为#import <React/RCTBundleURLProvider.h>

For me replacing对我来说更换

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

by

#import <RCTBundleURLProvider.h>
#import <RCTRootView.h>

in AppDelegate.m file worked.在 AppDelegate.m 文件中工作。

如果你还没有运行npm install你很可能会遇到这个问题。

我尝试了所有建议,但没有一个在我删除存储库并再次克隆它时对我有用,所以我的建议是提交您的更改备份它们并再次克隆对我有用的存储库。

I have gone through all the answers mentioned above.我已经完成了上面提到的所有答案。

Here is the solution worked for me:这是对我有用的解决方案:

STEP 1:第 1 步:

Run:运行:

npm install react-native-fcm --save 

This result in making the directory in your project under node_modules > react-native-fcm这导致在node_modules > react-native-fcm创建项目中的目录

将 react-native-fcm 添加到您的项目中

STEP 2:第 2 步:

You need to add '$(SRCROOT)/../node_modules/react-native-fcm/ios' to header search paths in build settings.您需要将'$(SRCROOT)/../node_modules/react-native-fcm/ios'到构建设置中的标头搜索路径。

添加到标题搜索路径

These 2 steps worked for me to remove the error.这两个步骤对我有用,可以消除错误。

For more details you can go through these links:有关更多详细信息,您可以访问以下链接:

https://github.com/evollu/react-native-fcm/issues/63 https://github.com/evollu/react-native-fcm/issues/63

https://github.com/evollu/react-native-fcm/issues/21 https://github.com/evollu/react-native-fcm/issues/21

For my case, I couldn't delete node_modules and re-install and I also couldn't do react-native-git-updgrade or react-native upgrade because I wanted to stay on RN-0.59 because .60 causes problems for my dependencies.就我而言,我无法删除 node_modules 并重新安装,也无法执行react-native-git-updgradereact-native upgrade因为我想继续使用 RN-0.59,因为 .60 会导致我的依赖项出现问题.

Anyway my situation was that I was missing 'React/RCTBundleURLProvider.h' file.无论如何,我的情况是我缺少“React/RCTBundleURLProvider.h”文件。 I already had React available in my schemas.我的模式中已经有 React 可用。 It was not in my libraries directory.它不在我的库目录中。 I checked my target 's build settings.我检查了我的target的构建设置。

Inside target dependencies, I also had React in there.在目标依赖项中,我也有 React。

I deleted 'React' target dependency, then re-added.我删除了“React”目标依赖项,然后重新添加。 cleaned build folders, re-built project.清理构建文件夹,重新构建项目。 it worked.它起作用了。

I am using React Native 0.61.我正在使用 React Native 0.61。 I created a Share Extension and was getting this error.我创建了一个共享扩展并收到此错误。 I needed to replace:我需要更换:

#import "RCTBundleURLProvider.h"

with

#import "React/RCTBundleURLProvider.h"

https://github.com/facebook/react-native/blob/v0.63.3/template/ios/Podfile https://github.com/facebook/react-native/blob/v0.63.3/template/ios/Podfile

Find/Replace HelloWorld with your your project name.使用您的项目名称查找/替换HelloWorld

Place this file into the ./ios folder in your project将此文件放入项目中的./ios文件夹中

gem install cocoapods
cd ios
pod install

Then open the YourProject.xcworkspace file in XCode然后在 XCode 中打开YourProject.xcworkspace文件

in XCode, go to Product -> Scheme -> Manage Schemes and check React在 XCode 中,转到Product -> Scheme -> Manage Schemes并检查React

Then try building the project again.然后再次尝试构建项目。

you need to install react native, in terminal run您需要在终端运行中安装 react native

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

then那么

brew install node
brew install watchman
npm install -g react-native-cli

source:来源:
https://facebook.github.io/react-native/docs/getting-started.html https://facebook.github.io/react-native/docs/getting-started.html

Make sure that the path to your project don't have any spaces.确保您的项目路径没有任何空格。 Just renaming folders and deleting spaces solves the problem for me.只需重命名文件夹和删除空格就可以解决我的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React Native 0.40.0:RCTBundleURLProvider.h“找不到文件 - AppDelegate.m - React Native 0.40.0 : RCTBundleURLProvider.h” file not found - AppDelegate.m [iOS] [v0.44]无法存档-在appDelegate.m中找不到“ React / RCTBundleURLProvider.h”文件 - [iOS][v0.44] Unable to archive - 'React/RCTBundleURLProvider.h' file not found in appDelegate.m 在react-native-fbsdk中找不到ReactNative&#39;React / RCTBundleURLProvider.h&#39;文件 - ReactNative 'React/RCTBundleURLProvider.h' file not found with react-native-fbsdk 将 react-native 从 0.59 更新到 0.61.4 后找不到“React/RCTBundleURLProvider.h”文件 - 'React/RCTBundleURLProvider.h' file not found after updating react-native from 0.59 to 0.61.4 在appdelegate.m文件中找不到viewcontroller - viewcontroller not found in appdelegate.m file #进口 <React/RCTBundleURLProvider.h> 找不到文件问题React Native ios - #import <React/RCTBundleURLProvider.h> file not found problem React Native ios 使用自定义xcode构建配置找不到“ React / RCTBundleURLProvider.h”文件 - 'React/RCTBundleURLProvider.h' file not found using custom xcode build configuration 在 AppDelegate.m 中找不到 React Native 'GoogleMaps/GoogleMaps.h' 文件: - React Native 'GoogleMaps/GoogleMaps.h' file not found in AppDelegate.m: 将AppDelegate.h和AppDelegate.m替换为AppDelegate.swift - Replace AppDelegate.h and AppDelegate.m to AppDelegate.swift AppDelegate.m文件中的两个程序包冲突 - Two packages conflict in AppDelegate.m file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM