From 4185fc4f4e85c898c4762e11c523bdf62a7703dd Mon Sep 17 00:00:00 2001 From: Christoph Purrer Date: Fri, 30 Oct 2026 23:23:40 -0700 Subject: [PATCH] Compile out RCTViewManager under RCT_REMOVE_LEGACY_COMPONENT_INTEROP - WIP (#59651) Summary: Consumers who opt into `RCT_REMOVE_LEGACY_COMPONENT_INTEROP` now get the Paper `RCTViewManager` base class compiled out, along with its property macros and the supporting `RCTComponentData` implementation. Any remaining subclass fails at compile time instead of shipping unreachable code. The flag defaults to off, so default builds are unaffected. Changelog: [iOS][Added] - Compile out the Paper `RCTViewManager` base when `RCT_REMOVE_LEGACY_COMPONENT_INTEROP` is set Differential Revision: D128434146 --- packages/react-native/React/Views/RCTComponentData.h | 4 ++++ packages/react-native/React/Views/RCTComponentData.mm | 4 ++++ packages/react-native/React/Views/RCTViewManager.h | 4 ++++ packages/react-native/React/Views/RCTViewManager.m | 4 ++++ .../NativeComponentExample/ios/RCTInteropTestViewManager.h | 4 ++++ .../NativeComponentExample/ios/RCTInteropTestViewManager.m | 4 ++++ .../ios/RNTMyLegacyNativeViewManager.mm | 4 ++++ .../NativeComponentExample/ios/RNTMyNativeViewManager.mm | 4 ++++ 8 files changed, 32 insertions(+) diff --git a/packages/react-native/React/Views/RCTComponentData.h b/packages/react-native/React/Views/RCTComponentData.h index e5c22a19c474..5f6ce2e8e2c5 100644 --- a/packages/react-native/React/Views/RCTComponentData.h +++ b/packages/react-native/React/Views/RCTComponentData.h @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP + #import #import @@ -48,3 +50,5 @@ NS_ASSUME_NONNULL_BEGIN RCT_EXTERN NSString *RCTViewManagerModuleNameForClass(Class managerClass); NS_ASSUME_NONNULL_END + +#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP diff --git a/packages/react-native/React/Views/RCTComponentData.mm b/packages/react-native/React/Views/RCTComponentData.mm index c857b4021478..70425ad70366 100644 --- a/packages/react-native/React/Views/RCTComponentData.mm +++ b/packages/react-native/React/Views/RCTComponentData.mm @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP + #import "RCTComponentData.h" #import @@ -550,3 +552,5 @@ - (void)setProps:(NSDictionary *)props forView:(id } @end + +#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP diff --git a/packages/react-native/React/Views/RCTViewManager.h b/packages/react-native/React/Views/RCTViewManager.h index ed17a436d861..014d30d888d3 100644 --- a/packages/react-native/React/Views/RCTViewManager.h +++ b/packages/react-native/React/Views/RCTViewManager.h @@ -21,6 +21,8 @@ typedef void (^RCTViewManagerUIBlock)(RCTUIManager *uiManager, NSDictionary *viewRegistry); +#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP + @interface RCTViewManager : NSObject /** @@ -119,3 +121,5 @@ typedef void (^RCTViewManagerUIBlock)(RCTUIManager *uiManager, NSDictionary +#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP + NS_ASSUME_NONNULL_BEGIN @interface InteropTestViewManager : RCTViewManager @end NS_ASSUME_NONNULL_END + +#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP diff --git a/packages/rn-tester/NativeComponentExample/ios/RCTInteropTestViewManager.m b/packages/rn-tester/NativeComponentExample/ios/RCTInteropTestViewManager.m index ac76554a849c..1d4491ee8141 100644 --- a/packages/rn-tester/NativeComponentExample/ios/RCTInteropTestViewManager.m +++ b/packages/rn-tester/NativeComponentExample/ios/RCTInteropTestViewManager.m @@ -8,6 +8,8 @@ #import "RCTInteropTestViewManager.h" #import "RCTInteropTestView.h" +#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP + @implementation InteropTestViewManager RCT_EXPORT_MODULE(InteropTestView) @@ -18,3 +20,5 @@ - (UIView *)view } @end + +#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP diff --git a/packages/rn-tester/NativeComponentExample/ios/RNTMyLegacyNativeViewManager.mm b/packages/rn-tester/NativeComponentExample/ios/RNTMyLegacyNativeViewManager.mm index 35585daff495..2ef6c21118a8 100644 --- a/packages/rn-tester/NativeComponentExample/ios/RNTMyLegacyNativeViewManager.mm +++ b/packages/rn-tester/NativeComponentExample/ios/RNTMyLegacyNativeViewManager.mm @@ -12,6 +12,8 @@ #import "RNTMyNativeViewComponentView.h" #import "UIView+ColorOverlays.h" +#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP + @interface RNTMyLegacyNativeViewManager : RCTViewManager @end @@ -86,3 +88,5 @@ - (NSDictionary *)constantsToExport return @{@"PI" : @3.14}; } @end + +#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP diff --git a/packages/rn-tester/NativeComponentExample/ios/RNTMyNativeViewManager.mm b/packages/rn-tester/NativeComponentExample/ios/RNTMyNativeViewManager.mm index 147da4612ff2..f9f7b33f82e0 100644 --- a/packages/rn-tester/NativeComponentExample/ios/RNTMyNativeViewManager.mm +++ b/packages/rn-tester/NativeComponentExample/ios/RNTMyNativeViewManager.mm @@ -10,6 +10,8 @@ #import #import "UIView+ColorOverlays.h" +#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP + @interface RNTMyNativeViewManager : RCTViewManager @end @@ -42,3 +44,5 @@ - (UIView *)view } @end + +#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP