Skip to content

Commit 2ea9b2e

Browse files
Deprecate old-arch bridge APIs unused by interop (#59544)
Summary: 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 9add5b6 commit 2ea9b2e

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
@@ -41,7 +41,8 @@ NSString *RCTBridgeModuleNameForClass(Class bridgeModuleClass);
4141
/**
4242
* This function returns the list of modules that have been registered using the Old Architecture mechanism.
4343
*/
44-
NSMutableArray<NSString *> *getModulesLoadedWithOldArch(void);
44+
NSMutableArray<NSString *> *getModulesLoadedWithOldArch(void)
45+
__deprecated_msg("This API will be removed along with the legacy architecture.");
4546

4647
#ifndef RCT_REMOVE_LEGACY_MODULE_INTEROP
4748
// Turn on TurboModule interop
@@ -128,7 +129,9 @@ RCT_EXTERN_C_END
128129
*
129130
* @experimental
130131
*/
131-
- (void)registerSegmentWithId:(NSUInteger)segmentId path:(NSString *)path;
132+
- (void)registerSegmentWithId:(NSUInteger)segmentId
133+
path:(NSString *)path
134+
__deprecated_msg("This API will be removed along with the legacy architecture.");
132135

133136
/**
134137
* Retrieve a bridge module instance by name or class. Note that modules are
@@ -184,7 +187,8 @@ RCT_EXTERN_C_END
184187
* The class of the executor currently being used. Changes to this value will
185188
* take effect after the bridge is reloaded.
186189
*/
187-
@property (nonatomic, strong) Class executorClass;
190+
@property (nonatomic, strong)
191+
Class executorClass __deprecated_msg("This API will be removed along with the legacy architecture.");
188192

189193
/**
190194
* The delegate provided during the bridge initialization
@@ -194,22 +198,26 @@ RCT_EXTERN_C_END
194198
/**
195199
* The launch options that were used to initialize the bridge.
196200
*/
197-
@property (nonatomic, copy, readonly) NSDictionary *launchOptions;
201+
@property (nonatomic, copy, readonly)
202+
NSDictionary *launchOptions __deprecated_msg("This API will be removed along with the legacy architecture.");
198203

199204
/**
200205
* Use this to check if the bridge is currently loading.
201206
*/
202-
@property (nonatomic, readonly, getter=isLoading) BOOL loading;
207+
@property (nonatomic, readonly, getter=isLoading)
208+
BOOL loading __deprecated_msg("This API will be removed along with the legacy architecture.");
203209

204210
/**
205211
* Use this to check if the bridge has been invalidated.
206212
*/
207-
@property (nonatomic, readonly, getter=isValid) BOOL valid;
213+
@property (nonatomic, readonly, getter=isValid)
214+
BOOL valid __deprecated_msg("This API will be removed along with the legacy architecture.");
208215

209216
/**
210217
* Link to the Performance Logger that logs React Native perf events.
211218
*/
212-
@property (nonatomic, readonly, strong) RCTPerformanceLogger *performanceLogger;
219+
@property (nonatomic, readonly, strong) RCTPerformanceLogger *performanceLogger __deprecated_msg(
220+
"This API will be removed along with the legacy architecture.");
213221

214222
/**
215223
* Reload the bundle and reset executor & modules. Safe to call from any thread.
@@ -224,7 +232,7 @@ RCT_EXTERN_C_END
224232
/**
225233
* Handle notifications for a fast refresh. Safe to call from any thread.
226234
*/
227-
- (void)onFastRefresh;
235+
- (void)onFastRefresh __deprecated_msg("This API will be removed along with the legacy architecture.");
228236

229237
/**
230238
* Inform the bridge, and anything subscribing to it, that it should reload.

‎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
@@ -553,7 +553,10 @@ - (void)_logOldArchitectureWarnings
553553
return;
554554
}
555555

556+
#pragma clang diagnostic push
557+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
556558
NSArray<NSString *> *modulesInOldArchMode = [getModulesLoadedWithOldArch() copy];
559+
#pragma clang diagnostic pop
557560
if (modulesInOldArchMode.count > 0) {
558561
NSMutableString *moduleList = [NSMutableString new];
559562
for (NSString *moduleName in modulesInOldArchMode) {

0 commit comments

Comments
 (0)