Skip to content

Commit

Permalink
Set InspectorFlags in RCTAppDelegate (#41976)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #41976

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

fbshipit-source-id: 1688f97c69abb06d271b4d26b875365a8d86ba77
  • Loading branch information
huntie authored and facebook-github-bot committed Dec 19, 2023
1 parent 11d3e11 commit 7a4950b
Show file tree
Hide file tree
Showing 4 changed files with 33 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
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Pod::Spec.new do |s|
add_dependency(s, "React-utils")
add_dependency(s, "React-debug")
add_dependency(s, "React-rendererdebug")
add_dependency(s, "React-jsinspector")

if use_hermes
s.dependency "React-hermes"
Expand Down

0 comments on commit 7a4950b

Please sign in to comment.