diff --git a/packages/react-native/React/Base/RCTBridge.h b/packages/react-native/React/Base/RCTBridge.h index aa8b7f1cb9a9..6ac477ead300 100644 --- a/packages/react-native/React/Base/RCTBridge.h +++ b/packages/react-native/React/Base/RCTBridge.h @@ -56,9 +56,11 @@ BOOL RCTTurboModuleInteropEnabled(void); void RCTEnableTurboModuleInterop(BOOL enabled); #endif // RCT_REMOVE_LEGACY_MODULE_INTEROP +#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP // Turn on the fabric interop layer BOOL RCTFabricInteropLayerEnabled(void); void RCTEnableFabricInteropLayer(BOOL enabled); +#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP BOOL RCTUIManagerDispatchAccessibilityManagerInitOntoMain(void); void RCTUIManagerSetDispatchAccessibilityManagerInitOntoMain(BOOL enabled); diff --git a/packages/react-native/React/Base/RCTBridge.mm b/packages/react-native/React/Base/RCTBridge.mm index 93abc6d93c5c..2b106acdda78 100644 --- a/packages/react-native/React/Base/RCTBridge.mm +++ b/packages/react-native/React/Base/RCTBridge.mm @@ -211,6 +211,7 @@ void RCTEnableTurboModuleInterop(BOOL enabled) } #endif // RCT_REMOVE_LEGACY_MODULE_INTEROP +#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP static BOOL fabricInteropLayerEnabled = YES; BOOL RCTFabricInteropLayerEnabled() { @@ -221,6 +222,7 @@ void RCTEnableFabricInteropLayer(BOOL enabled) { fabricInteropLayerEnabled = enabled; } +#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP static RCTBridgeProxyLoggingLevel bridgeProxyLoggingLevel = kRCTBridgeProxyLoggingLevelNone; RCTBridgeProxyLoggingLevel RCTTurboModuleInteropBridgeProxyLogLevel(void) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.h b/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.h index 9ad322f0d548..8a7976253b96 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.h +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.h @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP + #import #import @@ -30,3 +32,5 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END + +#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm index 226781f27bff..cc081964b1f3 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm @@ -7,6 +7,8 @@ #import "RCTLegacyViewManagerInteropComponentView.h" +#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP + #import #import #import @@ -299,3 +301,5 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event } @end + +#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropCoordinatorAdapter.h b/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropCoordinatorAdapter.h index 23549b1ab431..d6d57e59cd32 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropCoordinatorAdapter.h +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropCoordinatorAdapter.h @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP + #import #import @@ -25,3 +27,5 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END + +#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropCoordinatorAdapter.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropCoordinatorAdapter.mm index 39ff5f7bb72a..3b37e7bc7d90 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropCoordinatorAdapter.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropCoordinatorAdapter.mm @@ -6,6 +6,9 @@ */ #import "RCTLegacyViewManagerInteropCoordinatorAdapter.h" + +#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP + #import #import @@ -146,3 +149,5 @@ - (BOOL)_propIsSameObject:(id)first second:(id)second } @end + +#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP diff --git a/packages/react-native/React/Fabric/Mounting/RCTComponentViewFactory.mm b/packages/react-native/React/Fabric/Mounting/RCTComponentViewFactory.mm index 608d75cadf92..ddf36b229594 100644 --- a/packages/react-native/React/Fabric/Mounting/RCTComponentViewFactory.mm +++ b/packages/react-native/React/Fabric/Mounting/RCTComponentViewFactory.mm @@ -32,7 +32,9 @@ #import #import #import +#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP #import +#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP #import #import #import @@ -125,11 +127,6 @@ - (void)_registerComponentIfPossible:(const std::string &)name return; } - // Paper name: we prepare this variables to warn the user - // when the component is registered in both Fabric and in the - // interop layer, so they can remove that - NSString *componentNameString = RCTNSStringFromString(name); - // Fallback 1: Call provider function for component view class. Class klass = RCTComponentViewClassWithName(name.c_str()); if (klass != nullptr) { @@ -149,6 +146,12 @@ - (void)_registerComponentIfPossible:(const std::string &)name } } +#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP + // Paper name: we prepare this variables to warn the user + // when the component is registered in both Fabric and in the + // interop layer, so they can remove that + NSString *componentNameString = RCTNSStringFromString(name); + // Fallback 3: Try to use Paper Interop. // TODO(T174674274): Implement lazy loading of legacy view managers in the new architecture. if (RCTFabricInteropLayerEnabled() && [RCTLegacyViewManagerInteropComponentView isSupported:componentNameString]) { @@ -166,6 +169,7 @@ - (void)_registerComponentIfPossible:(const std::string &)name _registrationStatusMap.insert({provider.name, true}); return; } +#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP // Fallback 4: use if component doesn't exist. auto flavor = std::make_shared(name); diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm index 384957a3e9c7..c3eefd433636 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm +++ b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm @@ -758,6 +758,7 @@ - (Class)_getModuleClassFromName:(const char *)moduleName return moduleClass; } +#ifndef RCT_REMOVE_LEGACY_MODULE_INTEROP // fallback on modules registered throught RCT_EXPORT_MODULE with custom names NSString *objcModuleName = [NSString stringWithUTF8String:moduleName]; NSArray *modules = RCTGetModuleClasses(); @@ -767,6 +768,7 @@ - (Class)_getModuleClassFromName:(const char *)moduleName return current; } } +#endif return moduleClass; } diff --git a/packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/platform/ios/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.mm b/packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/platform/ios/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.mm index a1932ea25643..b6a915424b07 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/platform/ios/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.mm +++ b/packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/platform/ios/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.mm @@ -6,6 +6,9 @@ */ #include "LegacyViewManagerInteropComponentDescriptor.h" + +#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP + #include #include #include @@ -175,3 +178,5 @@ static Class getViewManagerClass(const std::string &componentName, RCTBridge *br legacyViewManagerInteropShadowNode.setStateData(std::move(state)); } } // namespace facebook::react + +#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP diff --git a/packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/platform/ios/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.h b/packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/platform/ios/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.h index 76279ecced5d..9777adeb5847 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/platform/ios/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.h +++ b/packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/platform/ios/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.h @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP + #import #import #import @@ -42,3 +44,5 @@ typedef void (^InterceptorBlock)(std::string eventName, folly::dynamic &&event); @end NS_ASSUME_NONNULL_END + +#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP diff --git a/packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/platform/ios/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm b/packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/platform/ios/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm index ce72f2e635d4..1057a57a5073 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/platform/ios/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm +++ b/packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/platform/ios/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm @@ -6,6 +6,9 @@ */ #include "RCTLegacyViewManagerInteropCoordinator.h" + +#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP + #include #include #include @@ -220,3 +223,5 @@ - (void)_lookupModuleMethodsIfNecessary } @end + +#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP diff --git a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm index 13ebbe825393..e744e34c7279 100644 --- a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm +++ b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm @@ -48,7 +48,9 @@ #import "ObjCTimerRegistry.h" #import "RCTJSThreadManager.h" +#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP #import "RCTLegacyUIManagerConstantsProvider.h" +#endif #import "RCTPerformanceLoggerUtils.h" #if RCT_DEV_MENU && __has_include() @@ -447,9 +449,11 @@ - (void)_start }); RCTInstallNativeComponentRegistryBinding(runtime); +#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP if (ReactNativeFeatureFlags::useNativeViewConfigsInBridgelessMode()) { installLegacyUIManagerConstantsProviderBinding(runtime); } +#endif [strongSelf->_delegate instance:strongSelf didInitializeRuntime:runtime];