Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS: You must override the supportedEvents method Error thrown when supportedEvents is implemented in super class #21333

Closed
3 tasks done
saumitrabhave opened this issue Sep 26, 2018 · 2 comments
Labels
Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@saumitrabhave
Copy link

saumitrabhave commented Sep 26, 2018

Environment

React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz
Memory: 140.67 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 9.11.1 - /usr/local/bin/node
npm: 5.6.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
Android SDK:
Build Tools: 21.1.2, 23.0.1, 24.0.0, 24.0.1, 25.0.0, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.2, 27.0.3, 28.0.2
API Levels: 22, 23, 24, 25, 26, 27, 28
IDEs:
Android Studio: 3.2 AI-181.5540.7.32.5014246
Xcode: 10.0/10A255 - /usr/bin/xcodebuild
npmPackages:
react: ^16.5.0 => 16.5.0
react-native: ^0.57.1 => 0.57.1
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
react-native-create-library: 3.1.2
react-native-git-upgrade: 0.2.7
react-native-webengage: 1.0.3

Description

RCTEventEmitter has a check implemented in class initializer to check that the Implementation being created implements 'supportedEvents' method. this is achieved here

But the RCTClassOverridesInstanceMethod method defined here uses class_copyMethodList obj-C Runtime method to get instance methods and iterate over them to see if required method is implemented.

as per Apple Docs class_copyMethodList does NOT return instance methods implemented by super classes.

This causes the app to crash in Dev mode (because of RCTAssert?) if the app has its own hierarchy of RCTEventEmitters, in which case the supportedEvents is implemented by an intermediate superclass between the current class and RCTEventEmitter.

IMO, the implementation should walk the inheritance hierarchy till RCTEventEmitter to make the correct assertion.

Reproducible Demo

Create a Native Module with One BaseEmitter which extends from RCTEventEmitter implement all the required functionalities also the supportedEvents method. Now create another class MainEmitter which extends from BaseEmitter, do not implement the supportedEvents method in MyEmitter to re-use implementation from BaseEmitter

App will crash on first use of MainEmitter

Note: Its a copy of #20687 because I could not update it on time with latest react version.

@stale
Copy link

stale bot commented Dec 25, 2018

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Dec 25, 2018
@stale
Copy link

stale bot commented Jan 2, 2019

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Jan 2, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Jan 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

2 participants