-
Notifications
You must be signed in to change notification settings - Fork 25k
feat(ios): Add a dev menu to RCTSurfaceHostingView #54441
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
Open
Saadnajmi
wants to merge
5
commits into
facebook:main
Choose a base branch
from
Saadnajmi:dev-menu-ios
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+92
−78
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Saadnajmi
commented
Nov 6, 2025
Comment on lines
-123
to
-136
| #ifndef RCT_REMOVE_LEGACY_ARCH | ||
| // Necessary to allow NativeModules to lookup TurboModules | ||
| [bridge setRCTTurboModuleRegistry:turboModuleManager]; | ||
|
|
||
| #if RCT_DEV | ||
| /** | ||
| * Instantiating DevMenu has the side-effect of registering | ||
| * shortcuts for CMD + d, CMD + i, and CMD + n via RCTDevMenu. | ||
| * Therefore, when TurboModules are enabled, we must manually create this | ||
| * NativeModule. | ||
| */ | ||
| [turboModuleManager moduleForName:"RCTDevMenu"]; | ||
| #endif // end RCT_DEV | ||
|
|
Contributor
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this is inside RCT_REMOVE_LEGACY_ARCH, I guess this code is technically frozen?
Saadnajmi
commented
Nov 6, 2025
Comment on lines
+223
to
+228
| if ([rootView isKindOfClass:[RCTSurfaceHostingView class]]) { | ||
| RCTDevMenu *devMenu = [bridge moduleForClass:[RCTDevMenu class]]; | ||
| if (devMenu) { | ||
| [(RCTSurfaceHostingView *)rootView setDevMenu:devMenu]; | ||
| } | ||
| } |
Contributor
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not entirely a fan of the class check here..
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
p: Microsoft
Partner: Microsoft
Partner
Shared with Meta
Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Mirrors microsoft#2749 but implemented upstream for iOS.
Currently, the hotkeys to open the dev menu, toggle element inspector, and reload are registered through
RCTKeyCommands. This is a global method that swizzles the application methods. This has a couple of issues:Lets instead set the key commands on the root view of each RN surface (
RCTSurfaceHostingView). To do this, we need to have access toRCTDevMenu, so I added it as a property toRCTSurfaceHostingViewthatRCTRootViewFactorycan set (since it has access to the module registery.Note 1: This does not replace the "reload" command yet, as that's registered from
RCTHost, and would need some more refactoring to switch.Note 2: I had originally implemented this by adding a
ContextContainertoRCTSurfaceHostingView, but that proved to be complicated, since that class is in React-Core and must compile as a swift module, which we can't do if we import stuff from ReactCommon. I found a way around this using private headers.. but the latest iteration seems cleaner. You can look at my earlier commits if you want to see what theContextContainerapporach involved.Changelog:
[IOS] [CHANGED] - Add a dev menu to RCTSurfaceHostingView
Test Plan:
I can launch the dev menu and toggle the element inspector from an iPhone or iPad Simulator