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 #20687

Closed
3 tasks done
saumitrabhave opened this issue Aug 16, 2018 · 4 comments
Labels
Platform: iOS iOS applications. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@saumitrabhave
Copy link

Environment

Environment:
OS: macOS High Sierra 10.13.2
Node: 9.11.1
Yarn: Not Found
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.2 => 0.55.2

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

@react-native-bot
Copy link
Collaborator

Can you reproduce the issue on the latest release, v0.56?

@saumitrabhave
Copy link
Author

saumitrabhave commented Aug 16, 2018

@react-native-bot Yes I can reproduce this issue in latest version as well.

@hramos
Copy link
Contributor

hramos commented Aug 16, 2018

Can you update your original issue accordingly?

@react-native-bot
Copy link
Collaborator

I am closing this issue because it does not appear to have been verified on the latest release, and there has been no followup in a while.

If you found this thread after encountering the same issue in the latest release, please feel free to create a new issue with up-to-date information by clicking here.

@react-native-bot react-native-bot added the Ran Commands One of our bots successfully processed a command. label Aug 31, 2018
@facebook facebook locked as resolved and limited conversation to collaborators Aug 31, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Aug 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: iOS iOS applications. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

3 participants