Dan
Dan

Reputation: 8824

React/RCTEventEmitter.h file not found

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

I am getting React/RCTEventEmitter file not found

I have completed the following steps:

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"

However, this is my problem

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

'React/RCTEventEmitter.h' file not found

Upvotes: 24

Views: 28449

Answers (10)

Florin Dobre
Florin Dobre

Reputation: 10252

For me this happened after switching the macbook from Intel to M4 (RN 0.72)

I had to enable Rosetta destination and run on a Rosetta iPhone to make the build work in Xcode:

enter image description here]1 enter image description here

Upvotes: 0

timjini
timjini

Reputation: 157

Today I uncounted the same issue and I could fix it with the following commands.

rm -rf node_modules
npm cache clean --force
npm install

then cd ios

pod install

Upvotes: 0

J.K.Rai
J.K.Rai

Reputation: 104

Replace #import RCTEventEmitter.h or #import React/RCTEventEmitter.h with #import <React/RCTEventEmitter.h>

Its work for me

Upvotes: 1

Danny Angeles
Danny Angeles

Reputation: 1

this worked for me!

add the missed lib manually

https://github.com/microsoft/react-native-code-push/issues/1565#issuecomment-489738672

Upvotes: 0

Govan
Govan

Reputation: 1389

USE those libraries:

follow step by step, everything will work no need anything else

not forget to

pod install

Upvotes: -1

Umair Riaz
Umair Riaz

Reputation: 476

Just follow these steps:

  1. create project react-native init project.
  2. add this line to pod file in ios folder: pod 'React-RCTPushNotification', :path => '../node_modules/react-native/Libraries/PushNotificationIOS'
  3. cd ios && pod install
  4. cd .. && react-native run-ios

No need to do messy manual linking

Upvotes: 3

chitzui
chitzui

Reputation: 4098

Since nothing mentioned above worked for me, I started experimenting, and this is what solved it for me:

1. Link React-Core & Public

As mentioned by Escamilla, in xcode open the RCTPushNotification.xcodeproj and under Build Settings search for header search path and add there the 2 path:

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

2. Copy RCTPushNotificationManager.h manually into React-Core

In the root folder of your project execute:

cp ./node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.h ./ios/Pods/Headers/Public/React-Core/React

This will copy RCTPushNotificationManager.h wich is in node_modules/react-native/Libraries/PushNotificationIOS/ manually into the React folder which is in ios/Pods/Headers/Public/React-Core/React.


I have no idea if that is a good solution but it works. Maybe if someone could explain me why it was not in there in the first place? That would be golden.

I followed the setup instructions 1 by 1 very carefully doing everything right but nothing worked except the manual copy mentioned above…

Also, this is randomly resetted once in a while and has to be done again -.-'

Upvotes: 7

Underdog
Underdog

Reputation: 815

This works for me on detached Expo project

"react": "16.6.3",
"react-native": "0.58.6",

Add 'RCTPushNotification' to your pod and run pod install

pod 'React', :path => '../node_modules/react-native', :subspecs => [    
    'RCTPushNotification',
  ]

Upvotes: 8

Niranjan Molkeri
Niranjan Molkeri

Reputation: 97

  1. Open up your project in XCode.
  2. Open up the Libraries folder. You should see React.xcodeproj and several RCT*.xcodeproj.
  3. Drag the React.xcodeproj into each of the other projects.
  4. Click on each project and navigate to the Build Phases tab.
  5. Click on Target Dependencies and add React as a target dependency

Upvotes: 4

Escamilla
Escamilla

Reputation: 331

@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.

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.

RCTPushNotification Target Build Settings 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.

enter image description here

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'

Upvotes: 21

Related Questions