From ec0dbb729d3774184dee83efbff5f9beebce72ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwas=CC=81niewski?= Date: Wed, 30 Oct 2024 11:24:19 -0700 Subject: [PATCH] feat: introduce RCTArchConfiguratorProtocol (#47306) Summary: This PR introduces `RCTArchConfiguratorProtocol` for better separation of concerns inside of RCTAppDelegate. It's also a prerequisite for https://github.com/facebook/react-native/issues/46298 Discussed with cipolleschi ## Changelog: [IOS] [ADDED] - introduce RCTArchConfiguratorProtocol Pull Request resolved: https://github.com/facebook/react-native/pull/47306 Test Plan: - CI Green - Test if methods can be overriden Reviewed By: realsoelynn Differential Revision: D65212703 Pulled By: cipolleschi fbshipit-source-id: 9850fec31c421f0c6230e7e23d7a208d823d828f --- .../Libraries/AppDelegate/RCTAppDelegate.h | 30 ++++------------- .../AppDelegate/RCTArchConfiguratorProtocol.h | 32 +++++++++++++++++++ 2 files changed, 39 insertions(+), 23 deletions(-) create mode 100644 packages/react-native/Libraries/AppDelegate/RCTArchConfiguratorProtocol.h diff --git a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h index 7f527665062..44af9901ccf 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h +++ b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h @@ -8,6 +8,7 @@ #import #import #import +#import "RCTArchConfiguratorProtocol.h" #import "RCTRootViewFactory.h" #import "RCTUIConfiguratorProtocol.h" @@ -56,8 +57,12 @@ NS_ASSUME_NONNULL_BEGIN (const facebook::react::ObjCTurboModule::InitParams &)params * - (id)getModuleInstanceFromClass:(Class)moduleClass */ -@interface RCTAppDelegate - : UIResponder +@interface RCTAppDelegate : UIResponder < + UIApplicationDelegate, + UISceneDelegate, + RCTBridgeDelegate, + RCTUIConfiguratorProtocol, + RCTArchConfiguratorProtocol> /// The window object, used to render the UViewControllers @property (nonatomic, strong, nonnull) UIWindow *window; @@ -107,27 +112,6 @@ NS_ASSUME_NONNULL_BEGIN /// @return a dictionary that associate a component for the new renderer with his descriptor. - (NSDictionary> *)thirdPartyFabricComponents; -/// This method controls whether the `turboModules` feature of the New Architecture is turned on or off. -/// -/// @note: This is required to be rendering on Fabric (i.e. on the New Architecture). -/// @return: `true` if the Turbo Native Module are enabled. Otherwise, it returns `false`. -- (BOOL)turboModuleEnabled __attribute__((deprecated("Use newArchEnabled instead"))); - -/// This method controls whether the App will use the Fabric renderer of the New Architecture or not. -/// -/// @return: `true` if the Fabric Renderer is enabled. Otherwise, it returns `false`. -- (BOOL)fabricEnabled __attribute__((deprecated("Use newArchEnabled instead"))); - -/// This method controls whether React Native's new initialization layer is enabled. -/// -/// @return: `true` if the new initialization layer is enabled. Otherwise returns `false`. -- (BOOL)bridgelessEnabled __attribute__((deprecated("Use newArchEnabled instead"))); - -/// This method controls whether React Native uses new Architecture. -/// -/// @return: `true` if the new architecture is enabled. Otherwise returns `false`. -- (BOOL)newArchEnabled; - /// Return the bundle URL for the main bundle. - (NSURL *__nullable)bundleURL; diff --git a/packages/react-native/Libraries/AppDelegate/RCTArchConfiguratorProtocol.h b/packages/react-native/Libraries/AppDelegate/RCTArchConfiguratorProtocol.h new file mode 100644 index 00000000000..ccd3c6b6f6c --- /dev/null +++ b/packages/react-native/Libraries/AppDelegate/RCTArchConfiguratorProtocol.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#import +#import + +@protocol RCTArchConfiguratorProtocol +/// This method controls whether the `turboModules` feature of the New Architecture is turned on or off. +/// +/// @note: This is required to be rendering on Fabric (i.e. on the New Architecture). +/// @return: `true` if the Turbo Native Module are enabled. Otherwise, it returns `false`. +- (BOOL)turboModuleEnabled __attribute__((deprecated("Use newArchEnabled instead"))); + +/// This method controls whether the App will use the Fabric renderer of the New Architecture or not. +/// +/// @return: `true` if the Fabric Renderer is enabled. Otherwise, it returns `false`. +- (BOOL)fabricEnabled __attribute__((deprecated("Use newArchEnabled instead"))); + +/// This method controls whether React Native's new initialization layer is enabled. +/// +/// @return: `true` if the new initialization layer is enabled. Otherwise returns `false`. +- (BOOL)bridgelessEnabled __attribute__((deprecated("Use newArchEnabled instead"))); + +/// This method controls whether React Native uses new Architecture. +/// +/// @return: `true` if the new architecture is enabled. Otherwise returns `false`. +- (BOOL)newArchEnabled; +@end