Skip to content

Commit 9045dd4

Browse files
christophpurrermeta-codesync[bot]
authored andcommitted
Drop legacy export macros when both interops are removed
Summary: Consumers who define both `RCT_REMOVE_LEGACY_MODULE_INTEROP` and `RCT_REMOVE_LEGACY_COMPONENT_INTEROP` now get the legacy `RCT_EXPORT_METHOD` family and `RCT_EXTERN_*` macros compiled out of `RCTBridgeModule.h`, so remaining legacy modules fail at compile time. `RCT_EXPORT_MODULE` stays available for TurboModules. Core modules keep plain method declarations under the flags, and in-repo legacy fixtures are compiled out. Changelog: [iOS][Added] - Compile out legacy `RCT_EXPORT_METHOD` and `RCT_EXTERN_*` macros when both `RCT_REMOVE_LEGACY_MODULE_INTEROP` and `RCT_REMOVE_LEGACY_COMPONENT_INTEROP` are set Reviewed By: shwanton Differential Revision: D133675552
1 parent ee2d411 commit 9045dd4

11 files changed

Lines changed: 51 additions & 0 deletions

File tree

‎packages/react-native-test-library/apple/TestLibraryApple.mm‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
#if !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)
9+
810
#import "TestLibraryApple.h"
911

1012
// Synth library products are emitted as .library(type: .dynamic, ...), so SPM
@@ -25,3 +27,5 @@ @implementation TestLibraryApple
2527
}
2628

2729
@end
30+
31+
#endif // !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)

‎packages/react-native-test-library/common/TestLibraryCommon.mm‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
#if !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)
9+
810
#import "TestLibraryCommon.h"
911

1012
@implementation TestLibraryCommon
@@ -22,3 +24,5 @@ + (NSString *)defaultPrefix
2224
}
2325

2426
@end
27+
28+
#endif // !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)

‎packages/react-native/React/Base/RCTBridgeModule.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ RCT_EXTERN_C_END
220220
*/
221221
@property (nonatomic, strong, readonly) dispatch_queue_t methodQueue RCT_DEPRECATED;
222222

223+
#if !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)
224+
223225
/**
224226
* Wrap the parameter line of your method implementation with this macro to
225227
* expose it to JS. By default the exposed method will match the first part of
@@ -371,6 +373,8 @@ RCT_EXTERN_C_END
371373
return &config; \
372374
}
373375

376+
#endif // !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)
377+
374378
/**
375379
* Most modules can be used from any thread. All of the modules exported non-sync method will be called on its
376380
* methodQueue, and the module will be constructed lazily when its first invoked. Some modules have main need to access

‎packages/react-native/React/CoreModules/RCTAppearance.mm‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ - (void)setColorScheme:(NSString *)style
125125
}
126126
}
127127
128+
#if !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)
128129
RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, getColorScheme)
130+
#else
131+
- (NSString *)getColorScheme
132+
#endif
129133
{
130134
return _currentColorScheme;
131135
}

‎packages/react-native/React/CoreModules/RCTDevToolsRuntimeSettingsModule.mm‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ - (void)setReloadAndProfileConfig:(JS::NativeReactDevToolsRuntimeSettingsModule:
3737
}
3838
}
3939

40+
#if !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)
4041
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(getReloadAndProfileConfig)
42+
#else
43+
- (id)getReloadAndProfileConfig
44+
#endif
4145
{
4246
return @{
4347
@"shouldReloadAndProfile" : @(_config.shouldReloadAndProfile),

‎packages/react-native/React/Modules/RCTEventEmitter.m‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@ - (void)invalidate
113113
}
114114
}
115115
116+
#if !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)
116117
RCT_EXPORT_METHOD(addListener : (NSString *)eventName)
118+
#else
119+
- (void)addListener:(NSString *)eventName
120+
#endif
117121
{
118122
if (_observationDisabled) {
119123
return;
@@ -132,7 +136,11 @@ - (void)invalidate
132136
}
133137
}
134138
139+
#if !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)
135140
RCT_EXPORT_METHOD(removeListeners : (double)count)
141+
#else
142+
- (void)removeListeners:(double)count
143+
#endif
136144
{
137145
if (_observationDisabled) {
138146
return;

‎packages/react-native/ReactCommon/react/nativemodule/core/iostests/RCTTurboModuleTests.mm‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
#if !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)
9+
810
#import <XCTest/XCTest.h>
911

1012
#import <React/RCTArrayBuffer.h>
@@ -397,3 +399,5 @@ - (void)testNativeBackedArrayBufferIsAliasedAndKeepsBackingStoreAlive
397399
}
398400

399401
@end
402+
403+
#endif // !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)

‎packages/react-native/ReactCommon/react/nativemodule/samples/platform/ios/ReactCommon/RCTSampleLegacyModule.mm‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
#if !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)
9+
810
#import "RCTSampleLegacyModule.h"
911

1012
@implementation RCTSampleLegacyModule
@@ -202,3 +204,5 @@ - (NSDictionary *)constantsToExport
202204
}
203205

204206
@end
207+
208+
#endif // !defined(RCT_REMOVE_LEGACY_MODULE_INTEROP) || !defined(RCT_REMOVE_LEGACY_COMPONENT_INTEROP)

‎packages/rn-tester/NativeModuleExample/Screenshot.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@
77

88
#import <React/RCTViewManager.h>
99

10+
#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP
11+
1012
@interface ScreenshotManager : RCTViewManager
1113
@end
14+
15+
#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP

‎packages/rn-tester/NativeModuleExample/Screenshot.mm‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
#import <React/RCTUIManager.h>
1111

12+
#ifndef RCT_REMOVE_LEGACY_COMPONENT_INTEROP
13+
1214
@implementation ScreenshotManager
1315

1416
RCT_EXPORT_MODULE();
@@ -83,3 +85,5 @@ @implementation ScreenshotManager
8385
}
8486
8587
@end
88+
89+
#endif // RCT_REMOVE_LEGACY_COMPONENT_INTEROP

0 commit comments

Comments
 (0)