software-mansion / react-native-gesture-handler

Declarative API exposing platform native touch and gesture system to React Native.
https://docs.swmansion.com/react-native-gesture-handler/
MIT License
5.85k stars 954 forks source link

Error: React/RCTEventDispatcher.h not found in iOS #179

Closed ikzjfr0 closed 5 years ago

ikzjfr0 commented 5 years ago

Following the instruction via:

  1. yarn react-native-gesture-handler
  2. react-native link react-native-gesture-handler

Then I compiled my Xcode project and got an issue: Error: React/RCTEventDispatcher.h not found image

My environment is: "react": "16.3.2", "react-native": "0.55.3", "react-native-gesture-handler": "^1.0.0",

By the way, is there a pod that I can use for Cocoapod in iOS?

osdnk commented 5 years ago

@ikzjfr0, Did you try 'Product->Clean' in Xcode and then build again?

ikzjfr0 commented 5 years ago

@osdnk yes plus deleting whole folder of Xcode/DerivedData and reboot my Macbook

ikzjfr0 commented 5 years ago

The error is removed after I changed from #import <React/RCTEventDispatcher.h> to #import "RCTEventDispatcher.h". However, I don't think it's a good way to do this since I also need to changes hundreds of files from <React/xxxx.h> to "xxxx.h"

Ideally, i think, it's better to use cocoapod way, rather than react-native link

ikzjfr0 commented 5 years ago

Seems we supports cocoapod since i can find out this: https://github.com/kmagiera/react-native-gesture-handler/blob/master/ios/RNGestureHandler.podspec

I tried to include following in podfile but got an error after pod install: pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'

osdnk commented 5 years ago

@ikzjfr0 I cannot manage to reproduce your issue. I made a new project react-native init, then: yarn add react-native-gesture-handler and: react-native link react-native-gesture-handler and find it workable. I also did change versions of react and RN to be exactly same as yours and build again the project and everything seems to be fine. Would you like to give me the link to repository with sample to project that shows your problem? Would you mind adding version of Xcode you use?

osdnk commented 5 years ago

@ikzjfr0 Maybe this solves your issue?

kmagiera commented 5 years ago

@ikzjfr0 I published 1.0.1 that includes #186

Do you mind trying that to see if it fixes your problem? If so we would like to close this issue.

ikzjfr0 commented 5 years ago

I still failed to use react-native link react-native-gesture-handler and got the same error as above. However, I managed to use cocoapod: pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler/ios, hope this is another right way to do that.

Moreover, i come to another issue (somebody else feedback this too) : https://github.com/react-native-community/react-native-tab-view/issues/408. I guess this could be potentially related to above issue too. react-native-tab-view is using react-native-gesture-handler as native drive.

osdnk commented 5 years ago

As it's the only issue describing such a problem and we cannot reproduce it, we consider it's related to https://github.com/react-native-community/react-native-tab-view/issues/408. If you still face the problem and haven't found a proper workaround, please reopen the issue

itaydressler commented 5 years ago

Still getting this issue. Did any one solve this?

osdnk commented 5 years ago

Could you please try remove your Xcode cache and npm cache as well?

hichamnaimi commented 5 years ago

If you are using react-link to link your dependencies: 1/ open your ios Podfile and delete all yout linked dependencies: pod 'xxxxxxx', :path => '../node_modules/xxxxx' 2/ Close Xcode 3/ In your /ios folder run "pod update" 4/ In your project source run "react-native link" 5/ Open Xcode and Clean Build Folder from Xcode Menu -> Product 6/ Run your application from Xcode 7/ Link manually the dependency "react-native-gesture-handler" into your Xcode Project following steps in documentation: https://facebook.github.io/react-native/docs/linking-libraries-ios 8/ Now run your application from Xcode, you should be fine.

TomBerriot commented 5 years ago

@hichamnaimi We can't use this solution as Sentry runs a blocking command program when running react-native link :/

@osdnk Same problem here, clearing every cache I could never resolved my issue.

Though replacing all #import <React/XXX> by #import "XXX" resolves building issues, it is in any way a solution as these files are always suppressed and redownloaded.

There seems to be an issue with how RNGestureHandler access React libraries that others don't have.

Would it be related to the old version of React (0.11.0) added and referenced in Podfile.lock by RNGestureHandler ?

In Podfile.lock

  - React (0.11.0):
    - React/Core (= 0.11.0)
  - React/Core (0.11.0)
  - RNGestureHandler (1.0.12):
    - React

I know little about Swift/Objective-C and Xcode. I've also cleaned Xcode project and rebuild multiple times and this doesn't do anything.

I tried linking RNGestureHandler manually instead of using react-native link react-native-gesture-handler did not work for me.

EDIT : Issue resolved, you also have to remove references added in the Podfile.lock. I thought manipulating Podfile.lock by hand would screw the podfile with the checksum.

cworsley4 commented 5 years ago

@hichamnaimi at which point should we add back our pods?

HelloJack0 commented 5 years ago

@TomBerriot I have same Podfile.lock, how to resolved it?

RONAKDHOLARIYA commented 4 years ago

I try all thing but still not resolved it please help me.

AndreyPatseiko commented 4 years ago

Have the same problem with RN 0.59.9

shyam-unnithan commented 4 years ago

I faced the same issue and have been able to resolve it. 1) Right click your App project in XCode and select "Add files to ". Browse to the node_modules/react-native-gesture-handler/ios and Select RNGestureHandler.xcodeproj and click add 2) Then Right click your RNGestureHandler.xcodeproj and select "Add files to RNGestureHander.xcodeproj" and browse to node_modules/react-native/React/ and select React.xcodeproj

Now do a clean in XCode and Build the app. You should now also be able to launch the app using react-native run-ios.

Cheers!

hchev001 commented 4 years ago

I faced the same issue and have been able to resolve it.

  1. Right click your App project in XCode and select "Add files to ". Browse to the node_modules/react-native-gesture-handler/ios and Select RNGestureHandler.xcodeproj and click add
  2. Then Right click your RNGestureHandler.xcodeproj and select "Add files to RNGestureHander.xcodeproj" and browse to node_modules/react-native/React/ and select React.xcodeproj

Now do a clean in XCode and Build the app. You should now also be able to launch the app using react-native run-ios.

Cheers!

@shyam-unnithan Thanks, step 2 solved the issue!

douglascavanaugh commented 4 years ago

Okay, here's my conundrum (I have installed all the latest versions of react-native and the herein defined dependencies). Firstly, I started from the top of this thread and worked my way down trying all suggestions and the result is, my Android works perfectly! However iOS doesn't.

I've followed the steps outlined by @shyam-unnithan, then:

error React Native CLI uses auto linking for native dependencies, but the following modules are linked manually: - react-native-gesture-handler (to unlink run: "react-native unlink react-native-gesture-handler")

and the build fails:

'React/RCTEventDispatcher.h' file not found #import <React/RCTEventDispatcher.h>

null is not an object (evaluating '_RNGestureHandlerModule.default.Direction')

chillios-dev commented 4 years ago

@douglascavanaugh Have you added use_native_modules! in your Podfile and run pod install after?

douglascavanaugh commented 4 years ago

No, but it was already there when I did run pod install:

Screen Shot 2019-07-13 at 6 56 55 PM

And here's the rest of the Podfile:

Screen Shot 2019-07-13 at 6 58 42 PM
denizbas92 commented 4 years ago

@osdnk yes plus deleting whole folder of Xcode/DerivedData and reboot my Macbook

I faced the same issue and have been able to resolve it.

  1. Right click your App project in XCode and select "Add files to ". Browse to the node_modules/react-native-gesture-handler/ios and Select RNGestureHandler.xcodeproj and click add
  2. Then Right click your RNGestureHandler.xcodeproj and select "Add files to RNGestureHander.xcodeproj" and browse to node_modules/react-native/React/ and select React.xcodeproj

Now do a clean in XCode and Build the app. You should now also be able to launch the app using react-native run-ios.

Cheers!

Hi, I have the same issue. Should I add RNGestureHandler.xcodeproj to Library Folder ?

shyam-unnithan commented 4 years ago

@osdnk yes plus deleting whole folder of Xcode/DerivedData and reboot my Macbook

I faced the same issue and have been able to resolve it.

  1. Right click your App project in XCode and select "Add files to ". Browse to the node_modules/react-native-gesture-handler/ios and Select RNGestureHandler.xcodeproj and click add
  2. Then Right click your RNGestureHandler.xcodeproj and select "Add files to RNGestureHander.xcodeproj" and browse to node_modules/react-native/React/ and select React.xcodeproj

Now do a clean in XCode and Build the app. You should now also be able to launch the app using react-native run-ios. Cheers!

Hi, I have the same issue. Should I add RNGestureHandler.xcodeproj to Library Folder ?

Follow step 1.

samchidi2005 commented 2 years ago

I added #import <React/RCTEventDispatcher.h> in the same file and it works with lots of warning.

cs-manughian commented 2 years ago

For me, I was able to do the following steps to get the build to succeed:

  1. yarn upgrade // This step is critical
  2. Clear Derived Data with DevCleaner
  3. cd ios then pod install
  4. Clean Build Folder in XCode
  5. Build project - Build succeeded!
aaryavrate commented 2 years ago

None of the above works for me. I tried all forms of tricks here, but none of it works. Tried following:

aaryavrate commented 2 years ago

I faced the same issue and have been able to resolve it.

  1. Right click your App project in XCode and select "Add files to ". Browse to the node_modules/react-native-gesture-handler/ios and Select RNGestureHandler.xcodeproj and click add
  2. Then Right click your RNGestureHandler.xcodeproj and select "Add files to RNGestureHander.xcodeproj" and browse to node_modules/react-native/React/ and select React.xcodeproj

Now do a clean in XCode and Build the app. You should now also be able to launch the app using react-native run-ios.

Cheers!

In my react-native/React there is no React. xcodeproj. image

My react-native version: "react-native": "~0.63.4",

RupamShaw commented 2 years ago

upgraded platform :ios, '11.0' to '12.0' in podfile having react-native 63.4 and "expo": "~41.0.1", can't Connect RNGestureHandler.xcodeproj & React.xcodeproj because n my react-native/React there is no React. xcodeproj.

How to resolve Error: React/RCTEventDispatcher.h not found in iOS

owencraston commented 1 year ago

I am still getting this error on my M1 Macbook with React Native 0.66. and "react-native-gesture-handler": "^1.10.3",

owencraston commented 1 year ago

I tried various ways of cleaning and reinstalling as well as deleting Xcode derived data and nothing worked. What fixed it for me was...

cd ios
pod deintegrate
pod setup
pod install
owencraston commented 1 year ago

I am sad to report that this hasn't solved my problem. It worked a few times but not every time.

I tried various ways of cleaning and reinstalling as well as deleting Xcode derived data and nothing worked. What fixed it for me was...

cd ios
pod deintegrate
pod setup
pod install
owencraston commented 1 year ago

My issue was a tad different as my error occurred inside the react-native-view-pager package. I was able to get passed this issue by running pod update inside my ios directory. I also updated my cocoapods version to CocoaPods: 1.12.1 with sudo gem install cocoapods but I don't think this was needed.