From f72f8daeaf20ae53e778143aecbb96303852aeb0 Mon Sep 17 00:00:00 2001 From: szymonrybczak Date: Tue, 14 Feb 2023 04:33:39 -0800 Subject: [PATCH] feat: add invoking dev menu on iOS by pressing `d` in terminal (#36115) Summary: Inspired by tido64's comment https://github.com/react-native-community/cli/issues/1820#issuecomment-1424270890 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: https://github.com/facebook/react-native/pull/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 --- React/CoreModules/RCTDevSettings.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/React/CoreModules/RCTDevSettings.mm b/React/CoreModules/RCTDevSettings.mm index e243eb0e0ade1e..e19a810d877364 100644 --- a/React/CoreModules/RCTDevSettings.mm +++ b/React/CoreModules/RCTDevSettings.mm @@ -117,6 +117,7 @@ - (void)_reloadWithDefaults:(NSDictionary *)defaultValues #if RCT_DEV_SETTINGS_ENABLE_PACKAGER_CONNECTION static RCTHandlerToken reloadToken; +static RCTHandlerToken devMenuToken; static std::atomic numInitializedModules{0}; #endif @@ -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 @@ -246,6 +255,9 @@ - (void)invalidate if (--numInitializedModules == 0) { [[RCTPackagerConnection sharedPackagerConnection] removeHandler:reloadToken]; +#if RCT_DEV_MENU + [[RCTPackagerConnection sharedPackagerConnection] removeHandler:devMenuToken]; +#endif } #endif }