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
This commit is contained in:
szymonrybczak
2023-02-14 04:33:39 -08:00
committed by Facebook GitHub Bot
parent 31ac1f8aec
commit f72f8daeaf
+12
View File
@@ -117,6 +117,7 @@ void RCTDevSettingsSetEnabled(BOOL enabled)
#if RCT_DEV_SETTINGS_ENABLE_PACKAGER_CONNECTION
static RCTHandlerToken reloadToken;
static RCTHandlerToken devMenuToken;
static std::atomic<int> numInitializedModules{0};
#endif
@@ -195,6 +196,14 @@ RCT_EXPORT_MODULE()
}
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 @@ RCT_EXPORT_MODULE()
if (--numInitializedModules == 0) {
[[RCTPackagerConnection sharedPackagerConnection] removeHandler:reloadToken];
#if RCT_DEV_MENU
[[RCTPackagerConnection sharedPackagerConnection] removeHandler:devMenuToken];
#endif
}
#endif
}