Skip to content

Commit fcb13c5

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 Pull Request resolved: #59544
1 parent 392b764 commit fcb13c5

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
@@ -117,7 +118,9 @@ RCT_EXTERN_C_END
117118
*
118119
* @experimental
119120
*/
120-
- (void)registerSegmentWithId:(NSUInteger)segmentId path:(NSString *)path;
121+
- (void)registerSegmentWithId:(NSUInteger)segmentId
122+
path:(NSString *)path
123+
__deprecated_msg("This API will be removed along with the legacy architecture.");
121124

122125
/**
123126
* Retrieve a bridge module instance by name or class. Note that modules are
@@ -157,31 +160,36 @@ RCT_EXTERN_C_END
157160
* The class of the executor currently being used. Changes to this value will
158161
* take effect after the bridge is reloaded.
159162
*/
160-
@property (nonatomic, strong) Class executorClass;
163+
@property (nonatomic, strong)
164+
Class executorClass __deprecated_msg("This API will be removed along with the legacy architecture.");
161165

162166
/**
163167
* The launch options that were used to initialize the bridge.
164168
*/
165-
@property (nonatomic, copy, readonly) NSDictionary *launchOptions;
169+
@property (nonatomic, copy, readonly)
170+
NSDictionary *launchOptions __deprecated_msg("This API will be removed along with the legacy architecture.");
166171

167172
/**
168173
* Use this to check if the bridge is currently loading.
169174
*/
170-
@property (nonatomic, readonly, getter=isLoading) BOOL loading;
175+
@property (nonatomic, readonly, getter=isLoading)
176+
BOOL loading __deprecated_msg("This API will be removed along with the legacy architecture.");
171177

172178
/**
173179
* Use this to check if the bridge has been invalidated.
174180
*/
175-
@property (nonatomic, readonly, getter=isValid) BOOL valid;
181+
@property (nonatomic, readonly, getter=isValid)
182+
BOOL valid __deprecated_msg("This API will be removed along with the legacy architecture.");
176183

177184
/**
178185
* Link to the Performance Logger that logs React Native perf events.
179186
*/
180-
@property (nonatomic, readonly, strong) RCTPerformanceLogger *performanceLogger;
187+
@property (nonatomic, readonly, strong) RCTPerformanceLogger *performanceLogger __deprecated_msg(
188+
"This API will be removed along with the legacy architecture.");
181189

182190
/**
183191
* Handle notifications for a fast refresh. Safe to call from any thread.
184192
*/
185-
- (void)onFastRefresh;
193+
- (void)onFastRefresh __deprecated_msg("This API will be removed along with the legacy architecture.");
186194

187195
@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
@@ -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)