Skip to content

Commit

Permalink
feat: add invoking dev menu on iOS by pressing d in terminal (#36115)
Browse files Browse the repository at this point in the history
Summary:
Inspired by tido64's comment react-native-community/cli#1820 (comment) I'm adding missing implementation on iOS for invoking dev menu by pressing `d` in terminal while metro is launched.

## Changelog

[IOS][ADDED] - Add invoking dev menu on iOS by pressing `d` in terminal.

Pull Request resolved: #36115

Test Plan:
Press `d` in terminal while metro is launched - dev menu should appear.

https://user-images.githubusercontent.com/63900941/217936561-deea1390-221e-4f32-bbc4-e6fcfdf2a992.mp4

Reviewed By: rshest

Differential Revision: D43185001

Pulled By: javache

fbshipit-source-id: daa7af3b24b1b9f10d1a1ef8db8d9af816e912ea
  • Loading branch information
szymonrybczak authored and facebook-github-bot committed Feb 14, 2023
1 parent 31ac1f8 commit f72f8da
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions React/CoreModules/RCTDevSettings.mm
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ - (void)_reloadWithDefaults:(NSDictionary *)defaultValues

#if RCT_DEV_SETTINGS_ENABLE_PACKAGER_CONNECTION
static RCTHandlerToken reloadToken;
static RCTHandlerToken devMenuToken;
static std::atomic<int> numInitializedModules{0};
#endif

Expand Down Expand Up @@ -195,6 +196,14 @@ - (void)initialize
}
queue:dispatch_get_main_queue()
forMethod:@"reload"];
#if RCT_DEV_MENU
devMenuToken = [[RCTPackagerConnection sharedPackagerConnection]
addNotificationHandler:^(id params) {
[self.bridge.devMenu show];
}
queue:dispatch_get_main_queue()
forMethod:@"devMenu"];
#endif
}
#endif

Expand Down Expand Up @@ -246,6 +255,9 @@ - (void)invalidate

if (--numInitializedModules == 0) {
[[RCTPackagerConnection sharedPackagerConnection] removeHandler:reloadToken];
#if RCT_DEV_MENU
[[RCTPackagerConnection sharedPackagerConnection] removeHandler:devMenuToken];
#endif
}
#endif
}
Expand Down

0 comments on commit f72f8da

Please sign in to comment.