Skip to content

Commit 951efc8

Browse files
cipolleschifacebook-github-bot
authored andcommitted
Remove some usages of RCT_NEW_ARCH_ENABLED (facebook#41589)
Summary: Pull Request resolved: facebook#41589 This is a cleanup diffs that removes some of the usages of RCT_NEW_ARCH_ENABLED. Now that we are shipping all the pods, there is no need to conditionally compile-out part of the codebase depending on whether the new architecture is running or not. This change will not alter the behavior of the app. ## Changelog: [iOS][Breaking] - Remove some usages of RCT_NEW_ARCH_ENABLED. The change should be transparent BUT some **Swift** libraries might get broken by this change. Reviewed By: dmytrorykun Differential Revision: D51498730 fbshipit-source-id: c83416480eea1f7bbc55f72c31e7b69ad0e9e01a
1 parent 6b53205 commit 951efc8

File tree

5 files changed

+37
-76
lines changed

5 files changed

+37
-76
lines changed

packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@
109109
/// @return: `YES` to use RuntimeScheduler, `NO` to use JavaScript scheduler. The default value is `YES`.
110110
- (BOOL)runtimeSchedulerEnabled;
111111

112-
#if RCT_NEW_ARCH_ENABLED
113112
@property (nonatomic, strong) RCTSurfacePresenterBridgeAdapter *bridgeAdapter;
114113

115114
/// This method returns a map of Component Descriptors and Components classes that needs to be registered in the
@@ -139,6 +138,4 @@
139138
/// Return the bundle URL for the main bundle.
140139
- (NSURL *)bundleURL;
141140

142-
#endif
143-
144141
@end

packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm

Lines changed: 36 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#import "RCTAppSetupUtils.h"
1414
#import "RCTLegacyInteropComponents.h"
1515

16-
#if RCT_NEW_ARCH_ENABLED
1716
#if RN_DISABLE_OSS_PLUGIN_HEADER
1817
#import <RCTTurboModulePlugin/RCTTurboModulePlugin.h>
1918
#else
@@ -51,19 +50,13 @@ @interface RCTAppDelegate () <
5150
}
5251
@end
5352

54-
#endif
55-
5653
static NSDictionary *updateInitialProps(NSDictionary *initialProps, BOOL isFabricEnabled)
5754
{
58-
#ifdef RCT_NEW_ARCH_ENABLED
5955
NSMutableDictionary *mutableProps = [initialProps mutableCopy] ?: [NSMutableDictionary new];
6056
// Hardcoding the Concurrent Root as it it not recommended to
6157
// have the concurrentRoot turned off when Fabric is enabled.
6258
mutableProps[kRNConcurrentRoot] = @(isFabricEnabled);
6359
return mutableProps;
64-
#else
65-
return initialProps;
66-
#endif
6760
}
6861

6962
@interface RCTAppDelegate () <RCTCxxBridgeDelegate> {
@@ -72,12 +65,9 @@ @interface RCTAppDelegate () <RCTCxxBridgeDelegate> {
7265
@end
7366

7467
@implementation RCTAppDelegate {
75-
#if RCT_NEW_ARCH_ENABLED
7668
RCTHost *_reactHost;
77-
#endif
7869
}
7970

80-
#if RCT_NEW_ARCH_ENABLED
8171
- (instancetype)init
8272
{
8373
if (self = [super init]) {
@@ -87,25 +77,20 @@ - (instancetype)init
8777
}
8878
return self;
8979
}
90-
#endif
9180

9281
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
9382
{
94-
BOOL enableTM = NO;
95-
BOOL enableBridgeless = NO;
96-
BOOL fabricEnabled = NO;
97-
#if RCT_NEW_ARCH_ENABLED
98-
enableTM = self.turboModuleEnabled;
99-
enableBridgeless = self.bridgelessEnabled;
100-
fabricEnabled = [self fabricEnabled];
101-
#endif
83+
BOOL enableTM = self.turboModuleEnabled;
84+
;
85+
BOOL enableBridgeless = self.bridgelessEnabled;
86+
BOOL fabricEnabled = self.fabricEnabled;
87+
10288
NSDictionary *initProps = updateInitialProps([self prepareInitialProps], fabricEnabled);
10389

10490
RCTAppSetupPrepareApp(application, enableTM);
10591

10692
UIView *rootView;
10793
if (enableBridgeless) {
108-
#if RCT_NEW_ARCH_ENABLED
10994
// Enable native view config interop only if both bridgeless mode and Fabric is enabled.
11095
RCTSetUseNativeViewConfigsInBridgelessMode(fabricEnabled);
11196

@@ -123,7 +108,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
123108
sizeMeasureMode:RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact];
124109

125110
rootView = (RCTRootView *)surfaceHostingProxyRootView;
126-
#endif
127111
} else {
128112
if (!self.bridge) {
129113
self.bridge = [self createBridgeWithDelegate:self launchOptions:launchOptions];
@@ -170,10 +154,7 @@ - (UIView *)createRootViewWithBridge:(RCTBridge *)bridge
170154
moduleName:(NSString *)moduleName
171155
initProps:(NSDictionary *)initProps
172156
{
173-
BOOL enableFabric = NO;
174-
#if RCT_NEW_ARCH_ENABLED
175-
enableFabric = self.fabricEnabled;
176-
#endif
157+
BOOL enableFabric = self.fabricEnabled;
177158
UIView *rootView = RCTAppSetupDefaultRootView(bridge, moduleName, initProps, enableFabric);
178159

179160
rootView.backgroundColor = [UIColor systemBackgroundColor];
@@ -223,7 +204,37 @@ - (void)windowScene:(UIWindowScene *)windowScene
223204
#endif
224205
}
225206

207+
#pragma mark - New Arch Enabled settings
208+
209+
- (BOOL)turboModuleEnabled
210+
{
211+
#if RCT_NEW_ARCH_ENABLED
212+
return YES;
213+
#else
214+
return NO;
215+
#endif
216+
}
217+
218+
- (BOOL)fabricEnabled
219+
{
226220
#if RCT_NEW_ARCH_ENABLED
221+
return YES;
222+
#else
223+
return NO;
224+
#endif
225+
}
226+
227+
- (BOOL)bridgelessEnabled
228+
{
229+
return NO;
230+
}
231+
232+
#pragma mark - RCTComponentViewFactoryComponentProvider
233+
234+
- (NSDictionary<NSString *, Class<RCTComponentViewProtocol>> *)thirdPartyFabricComponents
235+
{
236+
return @{};
237+
}
227238

228239
#pragma mark - RCTTurboModuleManagerDelegate
229240

@@ -254,30 +265,6 @@ - (Class)getModuleClassFromName:(const char *)name
254265
return RCTAppSetupDefaultModuleFromClass(moduleClass);
255266
}
256267

257-
#pragma mark - RCTComponentViewFactoryComponentProvider
258-
259-
- (NSDictionary<NSString *, Class<RCTComponentViewProtocol>> *)thirdPartyFabricComponents
260-
{
261-
return @{};
262-
}
263-
264-
#pragma mark - New Arch Enabled settings
265-
266-
- (BOOL)turboModuleEnabled
267-
{
268-
return YES;
269-
}
270-
271-
- (BOOL)fabricEnabled
272-
{
273-
return YES;
274-
}
275-
276-
- (BOOL)bridgelessEnabled
277-
{
278-
return NO;
279-
}
280-
281268
#pragma mark - New Arch Utilities
282269

283270
- (void)unstable_registerLegacyComponents
@@ -324,6 +311,4 @@ - (NSURL *)bundleURL
324311
return nullptr;
325312
}
326313

327-
#endif
328-
329314
@end

packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,23 @@
2626
#endif
2727
#endif
2828

29-
#if RCT_NEW_ARCH_ENABLED
3029
#import <ReactCommon/RCTTurboModuleManager.h>
31-
#endif
3230

3331
// Forward declaration to decrease compilation coupling
3432
namespace facebook::react {
3533
class RuntimeScheduler;
3634
}
3735

38-
#if RCT_NEW_ARCH_ENABLED
39-
4036
RCT_EXTERN id<RCTTurboModule> RCTAppSetupDefaultModuleFromClass(Class moduleClass);
4137

4238
std::unique_ptr<facebook::react::JSExecutorFactory> RCTAppSetupDefaultJsExecutorFactory(
4339
RCTBridge *bridge,
4440
RCTTurboModuleManager *turboModuleManager,
4541
const std::shared_ptr<facebook::react::RuntimeScheduler> &runtimeScheduler);
46-
#else
42+
4743
std::unique_ptr<facebook::react::JSExecutorFactory> RCTAppSetupJsExecutorFactoryForOldArch(
4844
RCTBridge *bridge,
4945
const std::shared_ptr<facebook::react::RuntimeScheduler> &runtimeScheduler);
50-
#endif
5146

5247
#endif // __cplusplus
5348

packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#import <react/renderer/runtimescheduler/RuntimeScheduler.h>
1212
#import <react/renderer/runtimescheduler/RuntimeSchedulerBinding.h>
1313

14-
#if RCT_NEW_ARCH_ENABLED
1514
// Turbo Module
1615
#import <React/RCTBundleAssetImageLoader.h>
1716
#import <React/RCTDataRequestHandler.h>
@@ -24,13 +23,10 @@
2423
// Fabric
2524
#import <React/RCTFabricSurface.h>
2625
#import <React/RCTSurfaceHostingProxyRootView.h>
27-
#endif
2826

2927
void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled)
3028
{
31-
#if RCT_NEW_ARCH_ENABLED
3229
RCTEnableTurboModule(turboModuleEnabled);
33-
#endif
3430

3531
#if DEBUG
3632
// Disable idle timer in dev builds to avoid putting application in background and complicating
@@ -42,18 +38,15 @@ void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled)
4238
UIView *
4339
RCTAppSetupDefaultRootView(RCTBridge *bridge, NSString *moduleName, NSDictionary *initialProperties, BOOL fabricEnabled)
4440
{
45-
#if RCT_NEW_ARCH_ENABLED
4641
if (fabricEnabled) {
4742
id<RCTSurfaceProtocol> surface = [[RCTFabricSurface alloc] initWithBridge:bridge
4843
moduleName:moduleName
4944
initialProperties:initialProperties];
5045
return [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface];
5146
}
52-
#endif
5347
return [[RCTRootView alloc] initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties];
5448
}
5549

56-
#if RCT_NEW_ARCH_ENABLED
5750
id<RCTTurboModule> RCTAppSetupDefaultModuleFromClass(Class moduleClass)
5851
{
5952
// Set up the default RCTImageLoader and RCTNetworking modules.
@@ -114,8 +107,6 @@ void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled)
114107
}));
115108
}
116109

117-
#else // else !RCT_NEW_ARCH_ENABLED
118-
119110
std::unique_ptr<facebook::react::JSExecutorFactory> RCTAppSetupJsExecutorFactoryForOldArch(
120111
RCTBridge *bridge,
121112
const std::shared_ptr<facebook::react::RuntimeScheduler> &runtimeScheduler)
@@ -134,4 +125,3 @@ void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled)
134125
}
135126
}));
136127
}
137-
#endif // end RCT_NEW_ARCH_ENABLED

packages/rn-tester/RNTester/AppDelegate.mm

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@
1616
#import <React/RCTPushNotificationManager.h>
1717
#endif
1818

19-
#if RCT_NEW_ARCH_ENABLED
2019
#import <NativeCxxModuleExample/NativeCxxModuleExample.h>
2120
#ifndef RN_DISABLE_OSS_PLUGIN_HEADER
2221
#import <RNTMyNativeViewComponentView.h>
2322
#endif
24-
#endif
2523

2624
// FB-internal imports
2725
#ifdef RN_DISABLE_OSS_PLUGIN_HEADER
@@ -88,11 +86,9 @@ - (void)loadSourceForBridge:(RCTBridge *)bridge
8886
if (name == std::string([@"SampleTurboCxxModule" UTF8String])) {
8987
return std::make_shared<facebook::react::SampleTurboCxxModule>(jsInvoker);
9088
}
91-
#ifdef RCT_NEW_ARCH_ENABLED
9289
if (name == facebook::react::NativeCxxModuleExample::kModuleName) {
9390
return std::make_shared<facebook::react::NativeCxxModuleExample>(jsInvoker);
9491
}
95-
#endif
9692
return nullptr;
9793
}
9894

@@ -129,7 +125,6 @@ - (void)application:(__unused UIApplication *)application
129125

130126
#pragma mark - RCTComponentViewFactoryComponentProvider
131127

132-
#if RCT_NEW_ARCH_ENABLED
133128
#ifndef RN_DISABLE_OSS_PLUGIN_HEADER
134129
- (nonnull NSDictionary<NSString *, Class<RCTComponentViewProtocol>> *)thirdPartyFabricComponents
135130
{
@@ -141,6 +136,5 @@ - (NSURL *)bundleURL
141136
{
142137
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:kBundlePath];
143138
}
144-
#endif
145139

146140
@end

0 commit comments

Comments
 (0)