Skip to content

Commit

Permalink
Set InspectorFlags in RCTAppDelegate (#41976)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
huntie authored and facebook-github-bot committed Dec 19, 2023
1 parent 21784e2 commit dd60aab
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
15 changes: 14 additions & 1 deletion packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#ifdef __cplusplus

#import <react/config/ReactNativeConfig.h>

#import <memory>

#ifndef RCT_USE_HERMES
Expand Down Expand Up @@ -44,11 +46,22 @@ std::unique_ptr<facebook::react::JSExecutorFactory> RCTAppSetupJsExecutorFactory
RCTBridge *bridge,
const std::shared_ptr<facebook::react::RuntimeScheduler> &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,
Expand Down
17 changes: 17 additions & 0 deletions packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#import <React/RCTFabricSurface.h>
#import <React/RCTSurfaceHostingProxyRootView.h>

// jsinspector-modern
#import <jsinspector-modern/InspectorFlags.h>

void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled)
{
RCTEnableTurboModule(turboModuleEnabled);
Expand All @@ -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)
{
Expand Down

0 comments on commit dd60aab

Please sign in to comment.