找不到React/RCTEventEmitter.h文件

Dan*_*Dan 16 react-native

我正在尝试使用独立的Expo应用程序实现PushNotificationIOS.我正在运行SDK 21.0.0(React Native 0.48).

我正进入(状态 React/RCTEventEmitter file not found

我已完成以下步骤:

  • 打开我的.xcworkspace项目
  • 将其RCTPushNotification.xcodeproj拖入我的Libraries文件夹
  • 添加libRCTPushNotification.aApp > Build Phases > Link Binary With Libraries
  • $(SRCROOT)/../node_modules/react-native/Libraries在标题搜索路径下添加- 我也试过没有/../.我也在Header Search Paths列表中有一堆Pod.

然后我添加了以下内容AppDelegate.m,但当我点击文件(⌘+ click)时,我收到一个问号.

#import <React/RCTPushNotificationManager.h>
Run Code Online (Sandbox Code Playgroud)

如果我将其更改为下面,它可以工作,我可以点击

#import "RCTPushNotificationManager.h"
Run Code Online (Sandbox Code Playgroud)

但是,这是我的问题

当我清理并构建我的项目时,我得到以下错误RCTPushNotificationManager.h:

'React/RCTEventEmitter.h' file not found
Run Code Online (Sandbox Code Playgroud)

小智 16

@Dan我遇到了同样的问题,它也发生在RCTLinking和其他依赖于eventEmitter.h和一个独立的Expo项目的库中.

问题是,自从Expo管理Cocoapods中的React以来,RCTPushNotification没有引用Cocoapods文件React中的React.因此,您应该进入RCTPushNotification.xcodeproj然后进入Targets - RCTPushNotification标头搜索路径并将链接添加到"ios/Pods/Headers/Public/React"并设置为递归.

RCTPushNotification目标构建设置 最简单的方法是导航到你的iOS/Pods/Headers/Public/React,然后将文件夹直接拖放到标题搜索路径的构建设置中,如下图所示.

在此输入图像描述

在此之后最后你必须引用ReactCommon/yoga,ReactCommon/yoga应该在你的'node_modules/react-native/ReactCommon/yoga'中

  • 这适用于我所有有此问题的`RCTxxxx``Libraries`。 (3认同)
  • 我正在尝试使用 .60,他们已将其重命名为“React-Core”,因此路径略有不同。这是一个合理的修复,但是如果您清理了 node_modules 文件夹,则必须重做此修复(正确吗?)。最后,这导致了另一个问题,React-Core 无法看到 Yoga/Yoga.h。我将手动链接所有内容,类似于 .57 的做法。 (2认同)

Und*_*dog 8

这对我适合独立世博会项目

"react": "16.6.3",
"react-native": "0.58.6",
Run Code Online (Sandbox Code Playgroud)

添加'RCTPushNotification'到您的pod并运行pod install

pod 'React', :path => '../node_modules/react-native', :subspecs => [    
    'RCTPushNotification',
  ]
Run Code Online (Sandbox Code Playgroud)

  • 这个解决方案在React 0.60上对我有用(可惜他们的文档没有这么说)。唯一的区别是我使用了以下行:`pod'React-RCTPushNotification',:path =&gt;'../node_modules/react-native/Libraries/PushNotificationIOS',而不是subspecs位。 (3认同)
  • `pod'React-RCTPushNotification',:path =&gt;'../node_modules/react-native/Libraries/PushNotificationIOS',并且撤消手动链接对我也有效– https://facebook.github.io上的说明/ react-native / docs / pushnotificationios似乎已过时。就这样浪费了半天。 (3认同)
  • @RaeesBhatti与pod安装一起,您不需要导入`xcodeproj`或手动链接`.a`文件。更新了我的pod文件之后(一定要删除Pods目录并再次运行`pod install`),我可以将#import &lt;React / RCTPushNotificationManager.h&gt;添加到我的AppDelegate.m中。所有其他项目都是自动的。 (2认同)

chi*_*zui 5

由于上面没有提到的对我有用,所以我开始尝试,这就是为我解决的问题:

1.链接React-Core和Public

正如Escamilla所提到的,在xcode中打开RCTPushNotification.xcodeproj和在Build Settings搜索下header search path并在其中添加2路径:

  • "$(SRCROOT)/../../../../ios/Pods/Headers/Public"
  • "$(SRCROOT)/../../../../ios/Pods/Headers/Public/React-Core"

2. RCTPushNotificationManager.h手动复制到React-Core

在项目的根文件夹中执行:

cp ./node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.h ./ios/Pods/Headers/Public/React-Core/React
Run Code Online (Sandbox Code Playgroud)

这将复制RCTPushNotificationManager.h至极是node_modules/react-native/Libraries/PushNotificationIOS/手动进React这是在文件夹中ios/Pods/Headers/Public/React-Core/React


我不知道这是否是一个很好的解决方案,但是可以。也许有人可以向我解释为什么它最初不在那儿?那将是黄金。

我非常仔细地按照设置说明进行了1到1的正确操作,但除上述手动副本外,其他操作均无效。

此外,这会偶尔随机重置,因此必须再次执行-.-'

  • 我花了大约两天的时间试图解决这个问题,并遇到了你的#1解决方案;它成功了。谢谢你! (2认同)