error: expected a type - eventDispatcher:(nonnull RCTEventDispatcher *)eventDispatcher; AND 'Undefined symbol' errors during iOS build

Viewed 1658

Cannot build iOS app after upgrading from RN version 0.63.2 to 0.65.0-rc.3. I am getting this error:

In file included from /Users/.../ReactNativeProjects/.../node_modules/react-native-gesture-handler/ios/RNGestureHandlerManager.m:1: /Users/.../ReactNativeProjects/.../node_modules/react-native-gesture-handler/ios/RNGestureHandlerManager.h:9:52: error: expected a type eventDispatcher:(nonnull RCTEventDispatcher *)eventDispatcher;

Problem is in RNGestureHandlerManager.h, on the line below:

- (nonnull instancetype)initWithUIManager:(nonnull RCTUIManager *)uiManager
                          eventDispatcher:(nonnull RCTEventDispatcher *)eventDispatcher;

enter image description here

When I upgrade to RNGestureHandler version 1.10.3 I get the errors below:

Undefined symbol: OBJC_CLASS$_RCTScrollView

Undefined symbol: OBJC_METACLASS$_RCTViewManager

Undefined symbol: OBJC_CLASS$_RCTEventEmitter

Undefined symbol: __RCTNotImplementedException

Undefined symbol: _RCTGetUIManagerQueue

Undefined symbol: OBJC_CLASS$_RCTConvert

Undefined symbol: _RCTRegisterModule

Undefined symbol: _RCTDefaultLogFunction

Undefined symbol: OBJC_CLASS$_RCTRootView

Undefined symbol: OBJC_METACLASS$_RCTEventEmitter

Undefined symbol: OBJC_CLASS$_RCTTouchHandler

Undefined symbol: OBJC_CLASS$_RCTViewManager

Undefined symbol: __RCTLogNativeInternal

It has been 3 days since I submitted the issue on the github page but no response from the team. I would really appreciate any help. Any ideas are welcome! This has really started to bother me.

Here is a link to the issue I created on github: https://github.com/software-mansion/react-native-gesture-handler/issues/1543

Thanks a lot...

enter image description here

3 Answers

Alright. After a couple of days of reading/digging and trying many different solutions this is how I fixed it.

1- Added the import statement below in RNGestureHandlerManager.h

#import <React/RCTEventDispatcher.h>

When I tried to re-build the app, this created the same Undefined symbol errors as if I had updated the RNGestureHandler version to 1.10.3 (see the red error messages in the question).

2- Here is the critical part.

I checked "ONLY_ACTIVE_ARCH" setting under Build Settings of the main project target. It was 'YES' for both debug and release modes.

enter image description here

Then I checked the same settings for RNGestureHandler package inside the Pods project. In my case, it was YES for debug and NO for release. I was trying to build the app in Release mode so I changed this setting to YES for release mode for the RNGestureHandler package.

Then I tried building my app again. This time the Undefined symbol errors for the RNGestureHandler package were gone. Similar messages started to show up for other packages. I did the same settings update for all the packages that created these Undefined symbol errors and finally, my app was built successfully in release mode! Hope this helps.

react-native-gesture-handled lib was upgraded and the fix is included, so upgrading the library will fix it.

This was fixed in a newer version of the lib.

In your package.json file, change the version of the react-native-gesture-handler lib to ~2.5.0 or higher. Then run yarn or npm i, followed by cd ios && pod install.

Related