未找到 React/RCTEventEmitter.h 文件 [英] React/RCTEventEmitter.h file not found

查看:49
本文介绍了未找到 React/RCTEventEmitter.h 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to implement PushNotificationIOS with a detached Expo app. I am running SDK 21.0.0 (React Native 0.48).

我收到 React/RCTEventEmitter 文件未找到

我已完成以下步骤:

  • 打开我的 .xcworkspace 项目
  • RCTPushNotification.xcodeproj 拖入我的 Libraries 文件夹
  • libRCTPushNotification.a 添加到 App >构建阶段将二进制文件与库链接
  • 在标题搜索路径下添加了 $(SRCROOT)/../node_modules/react-native/Libraries - 我也试过没有 /../.我在标题搜索路径"列表中也有一堆 Pod.
  • Open my .xcworkspace project
  • Drag the RCTPushNotification.xcodeproj into my Libraries folder
  • Added libRCTPushNotification.a into App > Build Phases > Link Binary With Libraries
  • Added $(SRCROOT)/../node_modules/react-native/Libraries under Header Search Paths - I also tried without the /../. I have a bunch of Pods in the Header Search Paths list too.

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

I then added the following into AppDelegate.m but when I click through to the file (⌘ + click), I get a question mark.

#import <React/RCTPushNotificationManager.h>

如果我把它改成下面的,就可以了,我可以点进去

If I change it to the below, it works, I can click through

#import "RCTPushNotificationManager.h"

但是,这是我的问题

当我清理和构建我的项目时,我在 RCTPushNotificationManager.h 中收到以下错误:

When I clean and build my project, I get the below error in RCTPushNotificationManager.h to say:

'React/RCTEventEmitter.h' file not found

推荐答案

@Dan 我遇到了这个完全相同的问题,它也发生在 RCTLinking 和其他依赖 eventEmitter.h 和分离的 Expo 项目的库中.

@Dan I have ran into this exact same issue, it also occurs for RCTLinking, and other libraries dependent on eventEmitter.h and a detached Expo project.

问题是 RCTPushNotification 没有从 Cocoapods 文件 React 引用 React,因为 Expo 在 Cocoapods 中管理 React.所以你应该进入 RCTPushNotification.xcodeproj 然后进入 Targets - RCTPushNotification Header Search Paths 并将链接添加到ios/Pods/Headers/Public/React"并设置为递归.

The issue turns out to be that RCTPushNotification doesn't have the reference to React from Cocoapods file React since Expo manages React in Cocoapods. So you should go into RCTPushNotification.xcodeproj then into Targets - RCTPushNotification Header Search Paths and add the link to "ios/Pods/Headers/Public/React" and set to recursive.

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

The easiest way to do the above is navigate to your iOS/Pods/Headers/Public/React and drag and drop the folder straight into build settings for header search paths like the below image.

在此之后最后提醒您,您很可能也必须引用 ReactCommon/yoga,但是 ReactCommon/yoga 应该在您的node_modules/react-native/ReactCommon/yoga"中

Heads up finally after this you will have to reference ReactCommon/yoga most likely as well, ReactCommon/yoga however should be in your 'node_modules/react-native/ReactCommon/yoga'

这篇关于未找到 React/RCTEventEmitter.h 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆