From 41c50fd20d56ac6209b363861cfb2c98a58767fd Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Wed, 10 Dec 2025 06:24:55 -0800 Subject: [PATCH] Fix build issues when RCT_REMOVE_LEGACY_ARCH is turned on internally (#54821) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/54821 This diff addresses build issues that arise when the `RCT_REMOVE_LEGACY_ARCH` flag is enabled internally. The changes ensure that the build process is compatible with the updated architecture. ## Changelog: [Internal] - Make sure that we can build using BUCK when the RCT_NEW_ARCH_ENABLED flag is turned on. Reviewed By: GijsWeterings Differential Revision: D88651074 fbshipit-source-id: 41d9d033c1160b5b8b4a7ad3db240e9cf7b50e38 --- .../AppDelegate/RCTReactNativeFactory.mm | 52 ++++++++----------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/packages/react-native/Libraries/AppDelegate/RCTReactNativeFactory.mm b/packages/react-native/Libraries/AppDelegate/RCTReactNativeFactory.mm index e1eecb0ae73..9de23e72cb8 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTReactNativeFactory.mm +++ b/packages/react-native/Libraries/AppDelegate/RCTReactNativeFactory.mm @@ -288,62 +288,51 @@ using namespace facebook::react; }; } +#ifndef RCT_REMOVE_LEGACY_ARCH + // When the Legacy Arch is removed, the Delegate does not have a extraLazyModuleClassesForBridge method if ([self.delegate respondsToSelector:@selector(extraLazyModuleClassesForBridge:)]) { configuration.extraLazyModuleClassesForBridge = ^NSDictionary *_Nonnull(RCTBridge *_Nonnull bridge) { -#ifndef RCT_REMOVE_LEGACY_ARCH return [weakSelf.delegate extraLazyModuleClassesForBridge:bridge]; -#else - // When the Legacy Arch is removed, the Delegate does not have a extraLazyModuleClassesForBridge method - return @{}; -#endif }; } +#endif +#ifndef RCT_REMOVE_LEGACY_ARCH + // When the Legacy Arch is removed, the Delegate does not have a bridge:didNotFindModule method + // We return NO, because if we have invoked this method is unlikely that the module will be actually registered if ([self.delegate respondsToSelector:@selector(bridge:didNotFindModule:)]) { configuration.bridgeDidNotFindModule = ^BOOL(RCTBridge *_Nonnull bridge, NSString *_Nonnull moduleName) { -#ifndef RCT_REMOVE_LEGACY_ARCH return [weakSelf.delegate bridge:bridge didNotFindModule:moduleName]; -#else - // When the Legacy Arch is removed, the Delegate does not have a bridge:didNotFindModule method - // We return NO, because if we have invoked this method is unlikely that the module will be actually registered - return NO; -#endif }; } +#endif +#ifndef RCT_REMOVE_LEGACY_ARCH + // When the Legacy Arch is removed, the Delegate does not have a + // loadSourceForBridge:onProgress:onComplete: method + // We then call the loadBundleAtURL:onProgress:onComplete: instead if ([self.delegate respondsToSelector:@selector(loadSourceForBridge:onProgress:onComplete:)]) { configuration.loadSourceForBridgeWithProgress = ^(RCTBridge *_Nonnull bridge, RCTSourceLoadProgressBlock _Nonnull onProgress, RCTSourceLoadBlock _Nonnull loadCallback) { -#ifndef RCT_REMOVE_LEGACY_ARCH [weakSelf.delegate loadSourceForBridge:bridge onProgress:onProgress onComplete:loadCallback]; -#else - // When the Legacy Arch is removed, the Delegate does not have a - // loadSourceForBridge:onProgress:onComplete: method - // We then call the loadBundleAtURL:onProgress:onComplete: instead - [weakSelf.delegate loadBundleAtURL:self.bundleURL onProgress:onProgress onComplete:loadCallback]; -#endif }; } +#endif +#ifndef RCT_REMOVE_LEGACY_ARCH + // When the Legacy Arch is removed, the Delegate does not have a + // loadSourceForBridge:withBlock: method + // We then call the loadBundleAtURL:onProgress:onComplete: instead if ([self.delegate respondsToSelector:@selector(loadSourceForBridge:withBlock:)]) { configuration.loadSourceForBridge = ^(RCTBridge *_Nonnull bridge, RCTSourceLoadBlock _Nonnull loadCallback) { -#ifndef RCT_REMOVE_LEGACY_ARCH [weakSelf.delegate loadSourceForBridge:bridge withBlock:loadCallback]; -#else - // When the Legacy Arch is removed, the Delegate does not have a - // loadSourceForBridge:withBlock: method - // We then call the loadBundleAtURL:onProgress:onComplete: instead - [weakSelf.delegate loadBundleAtURL:self.bundleURL - onProgress:^(RCTLoadingProgress *progressData) { - } - onComplete:loadCallback]; -#endif }; } +#endif configuration.jsRuntimeConfiguratorDelegate = self; @@ -371,15 +360,16 @@ using namespace facebook::react; static dispatch_once_t setupFeatureFlagsToken; dispatch_once(&setupFeatureFlagsToken, ^{ switch (releaseLevel) { - case Stable: - ReactNativeFeatureFlags::override(std::make_unique()); - break; case Canary: ReactNativeFeatureFlags::override(std::make_unique()); break; case Experimental: ReactNativeFeatureFlags::override(std::make_unique()); break; + case Stable: + default: + ReactNativeFeatureFlags::override(std::make_unique()); + break; } }); }