Skip to content

Commit dd379eb

Browse files
christophpurrermeta-codesync[bot]
authored andcommitted
Deprecate old-arch bridge APIs unused by interop (#59544)
Summary: Pull Request resolved: #59544 Mark the remaining old-architecture `RCTBridge` APIs that nothing in the interop layer calls as deprecated, so downstream modules get one release of warnings before removal: segment registration, executor/launch/loading/validity/performance accessors, fast refresh, callback enqueue, `batchedBridge`, block dispatch, extra module classes, and the old-arch module list. Silence the resulting warnings at the six first-party call sites. Changelog: [iOS][Deprecated] - Deprecate unused old-architecture `RCTBridge` APIs ahead of removal Reviewed By: andrewdacenko Differential Revision: D127822075
1 parent 39c03f5 commit dd379eb

4 files changed

Lines changed: 32 additions & 12 deletions

File tree

‎packages/react-native/React/Base/RCTBridge+Private.h‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,17 @@ RCT_EXTERN void RCTRegisterModule(Class);
2424
* This method is used to invoke a callback that was registered in the
2525
* JavaScript application context. Safe to call from any thread.
2626
*/
27-
- (void)enqueueCallback:(NSNumber *)cbID args:(NSArray *)args;
27+
- (void)enqueueCallback:(NSNumber *)cbID
28+
args:(NSArray *)args
29+
__deprecated_msg("This API will be removed along with the legacy architecture.");
2830

2931
/**
3032
* This property is mostly used on the main thread, but may be touched from
3133
* a background thread if the RCTBridge happens to deallocate on a background
3234
* thread. Therefore, we want all writes to it to be seen atomically.
3335
*/
34-
@property (atomic, strong) RCTBridge *batchedBridge;
36+
@property (atomic, strong)
37+
RCTBridge *batchedBridge __deprecated_msg("This API will be removed along with the legacy architecture.");
3538

3639
/**
3740
* An object that allows one to require NativeModules/TurboModules.
@@ -48,11 +51,14 @@ RCT_EXTERN void RCTRegisterModule(Class);
4851
* Dispatch work to a module's queue - this is also supports the fake RCTJSThread
4952
* queue. Exposed for the RCTProfiler
5053
*/
51-
- (void)dispatchBlock:(dispatch_block_t)block queue:(dispatch_queue_t)queue;
54+
- (void)dispatchBlock:(dispatch_block_t)block
55+
queue:(dispatch_queue_t)queue
56+
__deprecated_msg("This API will be removed along with the legacy architecture.");
5257

5358
/**
5459
* Registers additional classes with the ModuleRegistry.
5560
*/
56-
- (void)registerAdditionalModuleClasses:(NSArray<Class> *)newModules;
61+
- (void)registerAdditionalModuleClasses:(NSArray<Class> *)newModules
62+
__deprecated_msg("This API will be removed along with the legacy architecture.");
5763

5864
@end

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ NSString *RCTBridgeModuleNameForClass(Class bridgeModuleClass);
3131
/**
3232
* This function returns the list of modules that have been registered using the Old Architecture mechanism.
3333
*/
34-
NSMutableArray<NSString *> *getModulesLoadedWithOldArch(void);
34+
NSMutableArray<NSString *> *getModulesLoadedWithOldArch(void)
35+
__deprecated_msg("This API will be removed along with the legacy architecture.");
3536

3637
#ifndef RCT_REMOVE_LEGACY_MODULE_INTEROP
3738
// Turn on TurboModule interop
@@ -79,7 +80,9 @@ RCT_EXTERN_C_END
7980
*
8081
* @experimental
8182
*/
82-
- (void)registerSegmentWithId:(NSUInteger)segmentId path:(NSString *)path;
83+
- (void)registerSegmentWithId:(NSUInteger)segmentId
84+
path:(NSString *)path
85+
__deprecated_msg("This API will be removed along with the legacy architecture.");
8386

8487
/**
8588
* Retrieve a bridge module instance by name or class. Note that modules are
@@ -119,31 +122,36 @@ RCT_EXTERN_C_END
119122
* The class of the executor currently being used. Changes to this value will
120123
* take effect after the bridge is reloaded.
121124
*/
122-
@property (nonatomic, strong) Class executorClass;
125+
@property (nonatomic, strong)
126+
Class executorClass __deprecated_msg("This API will be removed along with the legacy architecture.");
123127

124128
/**
125129
* The launch options that were used to initialize the bridge.
126130
*/
127-
@property (nonatomic, copy, readonly) NSDictionary *launchOptions;
131+
@property (nonatomic, copy, readonly)
132+
NSDictionary *launchOptions __deprecated_msg("This API will be removed along with the legacy architecture.");
128133

129134
/**
130135
* Use this to check if the bridge is currently loading.
131136
*/
132-
@property (nonatomic, readonly, getter=isLoading) BOOL loading;
137+
@property (nonatomic, readonly, getter=isLoading)
138+
BOOL loading __deprecated_msg("This API will be removed along with the legacy architecture.");
133139

134140
/**
135141
* Use this to check if the bridge has been invalidated.
136142
*/
137-
@property (nonatomic, readonly, getter=isValid) BOOL valid;
143+
@property (nonatomic, readonly, getter=isValid)
144+
BOOL valid __deprecated_msg("This API will be removed along with the legacy architecture.");
138145

139146
/**
140147
* Link to the Performance Logger that logs React Native perf events.
141148
*/
142-
@property (nonatomic, readonly, strong) RCTPerformanceLogger *performanceLogger;
149+
@property (nonatomic, readonly, strong) RCTPerformanceLogger *performanceLogger __deprecated_msg(
150+
"This API will be removed along with the legacy architecture.");
143151

144152
/**
145153
* Handle notifications for a fast refresh. Safe to call from any thread.
146154
*/
147-
- (void)onFastRefresh;
155+
- (void)onFastRefresh __deprecated_msg("This API will be removed along with the legacy architecture.");
148156

149157
@end

‎packages/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ - (void)surface:(RCTSurface *)surface didChangeStage:(RCTSurfaceStage)stage
117117
{
118118
[super surface:surface didChangeStage:stage];
119119
if (RCTSurfaceStageIsRunning(stage)) {
120+
#pragma clang diagnostic push
121+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
120122
[_bridge.performanceLogger markStopForTag:RCTPLTTI];
123+
#pragma clang diagnostic pop
121124
#if TARGET_OS_TV
122125
dispatch_async(dispatch_get_main_queue(), ^{
123126
self.reactPreferredFocusedView = nil;

‎packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,10 @@ - (void)_logOldArchitectureWarnings
550550
return;
551551
}
552552

553+
#pragma clang diagnostic push
554+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
553555
NSArray<NSString *> *modulesInOldArchMode = [getModulesLoadedWithOldArch() copy];
556+
#pragma clang diagnostic pop
554557
if (modulesInOldArchMode.count > 0) {
555558
NSMutableString *moduleList = [NSMutableString new];
556559
for (NSString *moduleName in modulesInOldArchMode) {

0 commit comments

Comments
 (0)