From dd60aab0a616c6fb9fab2c33d49cdd1272704692 Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Tue, 19 Dec 2023 08:01:39 -0800 Subject: [PATCH] Set InspectorFlags in RCTAppDelegate (#41976) Summary: Progress towards an opt-in setup for our new CDP backend. - Wires up D51563107 to conditionally disable the legacy Hermes debugger via `ReactNativeConfig`. - **Configuration covered**: iOS, for the `RCTAppDelegate` code path. - Create C++-only overload of `RCTAppSetupPrepareApp`, deprecate the previous function. Changelog: [iOS][Deprecated] - Deprecate `RCTAppSetupPrepareApp`, replaced with C++ overload Reviewed By: motiz88 Differential Revision: D51589221 --- .../Libraries/AppDelegate/RCTAppDelegate.mm | 2 +- .../Libraries/AppDelegate/RCTAppSetupUtils.h | 15 ++++++++++++++- .../Libraries/AppDelegate/RCTAppSetupUtils.mm | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm index 3b29780304d69a..65c48ff28d2290 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm +++ b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm @@ -84,7 +84,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( NSDictionary *initProps = updateInitialProps([self prepareInitialProps], fabricEnabled); - RCTAppSetupPrepareApp(application, enableTM); + RCTAppSetupPrepareApp(application, enableTM, *_reactNativeConfig); UIView *rootView; if (enableBridgeless) { diff --git a/packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.h b/packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.h index d661fb4355c1c1..af14ba93b9178b 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.h +++ b/packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.h @@ -11,6 +11,8 @@ #ifdef __cplusplus +#import + #import #ifndef RCT_USE_HERMES @@ -44,11 +46,22 @@ std::unique_ptr RCTAppSetupJsExecutorFactory RCTBridge *bridge, const std::shared_ptr &runtimeScheduler); +/** + * Register features and experiments prior to app initialization. + */ +void RCTAppSetupPrepareApp( + UIApplication *application, + BOOL turboModuleEnabled, + const facebook::react::ReactNativeConfig &reactNativeConfig); + #endif // __cplusplus RCT_EXTERN_C_BEGIN -void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled); +[[deprecated("Use the 3-argument overload of RCTAppSetupPrepareApp instead")]] void RCTAppSetupPrepareApp( + UIApplication *application, + BOOL turboModuleEnabled); + UIView *RCTAppSetupDefaultRootView( RCTBridge *bridge, NSString *moduleName, diff --git a/packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm b/packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm index 7e522f9742bb45..68b1f417995446 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm +++ b/packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm @@ -24,6 +24,9 @@ #import #import +// jsinspector-modern +#import + void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled) { RCTEnableTurboModule(turboModuleEnabled); @@ -35,6 +38,20 @@ void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled) #endif } +void RCTAppSetupPrepareApp( + UIApplication *application, + BOOL turboModuleEnabled, + const facebook::react::ReactNativeConfig &reactNativeConfig) +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + RCTAppSetupPrepareApp(application, turboModuleEnabled); +#pragma clang diagnostic pop + + auto &inspectorFlags = facebook::react::jsinspector_modern::InspectorFlags::getInstance(); + inspectorFlags.initFromConfig(reactNativeConfig); +} + UIView * RCTAppSetupDefaultRootView(RCTBridge *bridge, NSString *moduleName, NSDictionary *initialProperties, BOOL fabricEnabled) {