Skip to content

Commit d503ea4

Browse files
cipolleschifacebook-github-bot
authored andcommitted
Add deprecation for legacy arch APIs (#53368)
Summary: Pull Request resolved: #53368 This change introduces deprecation messages for several APIs used by the legacy arch in the RCTAppDelegate Library ## Changelog: [iOS][Added] - Add deprecation message for RCTAppdelegate APIs Reviewed By: cortinico Differential Revision: D80618102 fbshipit-source-id: db77f8602a521557ed26822f27d54c6fc70c49bf
1 parent e723ca4 commit d503ea4

6 files changed

Lines changed: 59 additions & 34 deletions

File tree

packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,18 @@ __attribute__((deprecated(
6868
/// The window object, used to render the UViewControllers
6969
@property (nonatomic, strong, nonnull) UIWindow *window;
7070

71-
@property (nonatomic, nullable) RCTBridge *bridge;
71+
@property (nonatomic, nullable) RCTBridge *bridge
72+
__attribute__((deprecated("The bridge is deprecated and will be removed when removing the legacy architecture.")));
7273
@property (nonatomic, strong, nullable) NSString *moduleName;
7374
@property (nonatomic, strong, nullable) NSDictionary *initialProps;
7475
@property (nonatomic, strong) RCTReactNativeFactory *reactNativeFactory;
7576

7677
/// If `automaticallyLoadReactNativeWindow` is set to `true`, the React Native window will be loaded automatically.
7778
@property (nonatomic, assign) BOOL automaticallyLoadReactNativeWindow;
7879

79-
@property (nonatomic, nullable) RCTSurfacePresenterBridgeAdapter *bridgeAdapter;
80+
@property (nonatomic, nullable) RCTSurfacePresenterBridgeAdapter *bridgeAdapter __attribute__((
81+
deprecated("The bridge adapter is deprecated and will be removed when removing the legacy architecture.")));
82+
;
8083

8184
- (RCTRootViewFactory *)rootViewFactory;
8285

packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,20 @@ std::unique_ptr<facebook::react::JSExecutorFactory> RCTAppSetupDefaultJsExecutor
4040

4141
std::unique_ptr<facebook::react::JSExecutorFactory> RCTAppSetupJsExecutorFactoryForOldArch(
4242
RCTBridge *bridge,
43-
const std::shared_ptr<facebook::react::RuntimeScheduler> &runtimeScheduler);
43+
const std::shared_ptr<facebook::react::RuntimeScheduler> &runtimeScheduler)
44+
__attribute__((deprecated(
45+
"RCTAppSetupJsExecutorFactoryForOldArch(RCTBridge *, RuntimeScheduler) is deprecated and will be removed when we remove the legacy architecture.")));
46+
;
4447

4548
#endif // __cplusplus
4649

4750
RCT_EXTERN_C_BEGIN
4851

49-
void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled);
50-
UIView *RCTAppSetupDefaultRootView(
51-
RCTBridge *bridge,
52-
NSString *moduleName,
53-
NSDictionary *initialProperties,
54-
BOOL fabricEnabled);
52+
void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled) __attribute__((deprecated(
53+
"RCTAppSetupPrepareApp(UIApplication, BOOL) is deprecated and it's signature will change when we remove the legacy arch")));
54+
UIView *
55+
RCTAppSetupDefaultRootView(RCTBridge *bridge, NSString *moduleName, NSDictionary *initialProperties, BOOL fabricEnabled)
56+
__attribute__((deprecated(
57+
"RCTAppSetupDefaultRootView(RCTBridge *, NSString *, NSDictionary *, BOOL) is deprecated and it's signature will change when we remove the legacy arch")));
5558

5659
RCT_EXTERN_C_END

packages/react-native/Libraries/AppDelegate/RCTArchConfiguratorProtocol.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,29 @@
1010

1111
NS_ASSUME_NONNULL_BEGIN
1212

13+
__attribute__((deprecated(
14+
"RCTArchConfiguratorProtocol is deprecated and will be removed when we remove the legacy architecture.")));
1315
@protocol RCTArchConfiguratorProtocol
1416
/// This method controls whether the `turboModules` feature of the New Architecture is turned on or off.
1517
///
1618
/// @note: This is required to be rendering on Fabric (i.e. on the New Architecture).
1719
/// @return: `true` if the Turbo Native Module are enabled. Otherwise, it returns `false`.
18-
- (BOOL)turboModuleEnabled __attribute__((deprecated("Use RCTIsNewArchEnabled instead")));
20+
- (BOOL)turboModuleEnabled __attribute__((deprecated("This will be removed in a future version of React Native")));
1921

2022
/// This method controls whether the App will use the Fabric renderer of the New Architecture or not.
2123
///
2224
/// @return: `true` if the Fabric Renderer is enabled. Otherwise, it returns `false`.
23-
- (BOOL)fabricEnabled __attribute__((deprecated("Use RCTIsNewArchEnabled instead")));
25+
- (BOOL)fabricEnabled __attribute__((deprecated("This will be removed in a future version of React Native")));
2426

2527
/// This method controls whether React Native's new initialization layer is enabled.
2628
///
2729
/// @return: `true` if the new initialization layer is enabled. Otherwise returns `false`.
28-
- (BOOL)bridgelessEnabled __attribute__((deprecated("Use RCTIsNewArchEnabled instead")));
30+
- (BOOL)bridgelessEnabled __attribute__((deprecated("This will be removed in a future version of React Native")));
2931

3032
/// This method controls whether React Native uses new Architecture.
3133
///
3234
/// @return: `true` if the new architecture is enabled. Otherwise returns `false`.
33-
- (BOOL)newArchEnabled __attribute__((deprecated("Use RCTIsNewArchEnabled instead")));
35+
- (BOOL)newArchEnabled __attribute__((deprecated("This will be removed in a future version of React Native")));
3436
@end
3537

3638
NS_ASSUME_NONNULL_END

packages/react-native/Libraries/AppDelegate/RCTReactNativeFactory.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ typedef NS_ENUM(NSInteger, RCTReleaseLevel) { Canary, Experimental, Stable };
5656
*
5757
* @returns: a newly created instance of RCTBridge.
5858
*/
59-
- (RCTBridge *)createBridgeWithDelegate:(id<RCTBridgeDelegate>)delegate launchOptions:(NSDictionary *)launchOptions;
59+
- (RCTBridge *)createBridgeWithDelegate:(id<RCTBridgeDelegate>)delegate
60+
launchOptions:(NSDictionary *)launchOptions
61+
__attribute__((deprecated(
62+
"createBridgeWithDelegate:launchOptions: is deprecated and will be removed when removing the legacy architecture.")));
6063

6164
/**
6265
* It creates a `UIView` starting from a bridge, a module name and a set of initial properties.
@@ -72,7 +75,9 @@ typedef NS_ENUM(NSInteger, RCTReleaseLevel) { Canary, Experimental, Stable };
7275
*/
7376
- (UIView *)createRootViewWithBridge:(RCTBridge *)bridge
7477
moduleName:(NSString *)moduleName
75-
initProps:(NSDictionary *)initProps;
78+
initProps:(NSDictionary *)initProps
79+
__attribute__((deprecated(
80+
"createRootViewWithBridge:moduleName:initProps is deprecated and will be removed when removing the legacy architecture.")));
7681

7782
/// This method returns a map of Component Descriptors and Components classes that needs to be registered in the
7883
/// new renderer. The Component Descriptor is a string which represent the name used in JS to refer to the native
@@ -101,10 +106,13 @@ typedef NS_ENUM(NSInteger, RCTReleaseLevel) { Canary, Experimental, Stable };
101106
initialProperties:(NSDictionary *_Nullable)initialProperties
102107
launchOptions:(NSDictionary *_Nullable)launchOptions;
103108

104-
@property (nonatomic, nullable) RCTBridge *bridge;
109+
@property (nonatomic, nullable) RCTBridge *bridge
110+
__attribute__((deprecated("The bridge is deprecated and will be removed when removing the legacy architecture.")));
105111
@property (nonatomic, strong, nonnull) RCTRootViewFactory *rootViewFactory;
106112

107-
@property (nonatomic, nullable) RCTSurfacePresenterBridgeAdapter *bridgeAdapter;
113+
@property (nonatomic, nullable) RCTSurfacePresenterBridgeAdapter *bridgeAdapter __attribute__((
114+
deprecated("The bridgeAdapter is deprecated and will be removed when removing the legacy architecture.")));
115+
;
108116

109117
@property (nonatomic, weak) id<RCTReactNativeFactoryDelegate> delegate;
110118

packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,15 @@ typedef void (^RCTLoadSourceForBridgeBlock)(RCTBridge *bridge, RCTSourceLoadBloc
6565
- (instancetype)initWithBundleURLBlock:(RCTBundleURLBlock)bundleURLBlock
6666
newArchEnabled:(BOOL)newArchEnabled
6767
turboModuleEnabled:(BOOL)turboModuleEnabled
68-
bridgelessEnabled:(BOOL)bridgelessEnabled NS_DESIGNATED_INITIALIZER __deprecated;
68+
bridgelessEnabled:(BOOL)bridgelessEnabled __deprecated;
6969

7070
- (instancetype)initWithBundleURL:(NSURL *)bundleURL
7171
newArchEnabled:(BOOL)newArchEnabled
7272
turboModuleEnabled:(BOOL)turboModuleEnabled
7373
bridgelessEnabled:(BOOL)bridgelessEnabled __deprecated;
7474

75-
- (instancetype)initWithBundleURLBlock:(RCTBundleURLBlock)bundleURLBlock newArchEnabled:(BOOL)newArchEnabled;
75+
- (instancetype)initWithBundleURLBlock:(RCTBundleURLBlock)bundleURLBlock
76+
newArchEnabled:(BOOL)newArchEnabled NS_DESIGNATED_INITIALIZER;
7677

7778
- (instancetype)initWithBundleURL:(NSURL *)bundleURL newArchEnabled:(BOOL)newArchEnabled;
7879

packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.mm

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,22 @@ @implementation RCTRootViewFactoryConfiguration
3838

3939
- (instancetype)initWithBundleURL:(NSURL *)bundleURL newArchEnabled:(BOOL)newArchEnabled
4040
{
41-
return [self initWithBundleURL:bundleURL
42-
newArchEnabled:newArchEnabled
43-
turboModuleEnabled:newArchEnabled
44-
bridgelessEnabled:newArchEnabled];
41+
return [self initWithBundleURL:bundleURL];
4542
}
4643

4744
- (instancetype)initWithBundleURLBlock:(RCTBundleURLBlock)bundleURLBlock newArchEnabled:(BOOL)newArchEnabled
4845
{
49-
return [self initWithBundleURLBlock:bundleURLBlock
50-
newArchEnabled:newArchEnabled
51-
turboModuleEnabled:newArchEnabled
52-
bridgelessEnabled:newArchEnabled];
46+
return [self initWithBundleURLBlock:bundleURLBlock];
5347
}
5448

5549
- (instancetype)initWithBundleURL:(NSURL *)bundleURL
5650
newArchEnabled:(BOOL)newArchEnabled
5751
turboModuleEnabled:(BOOL)turboModuleEnabled
5852
bridgelessEnabled:(BOOL)bridgelessEnabled
5953
{
60-
return [self
61-
initWithBundleURLBlock:^{
62-
return bundleURL;
63-
}
64-
newArchEnabled:newArchEnabled
65-
turboModuleEnabled:turboModuleEnabled
66-
bridgelessEnabled:bridgelessEnabled];
54+
return [self initWithBundleURLBlock:^{
55+
return bundleURL;
56+
}];
6757
}
6858

6959
- (instancetype)initWithBundleURLBlock:(RCTBundleURLBlock)bundleURLBlock
@@ -80,6 +70,24 @@ - (instancetype)initWithBundleURLBlock:(RCTBundleURLBlock)bundleURLBlock
8070
return self;
8171
}
8272

73+
- (instancetype)initWithBundleURLBlock:(RCTBundleURLBlock)bundleURLBlock
74+
{
75+
if (self = [super init]) {
76+
_bundleURLBlock = bundleURLBlock;
77+
_fabricEnabled = YES;
78+
_turboModuleEnabled = YES;
79+
_bridgelessEnabled = YES;
80+
}
81+
return self;
82+
}
83+
84+
- (instancetype)initWithBundleURL:(NSURL *)bundleURL
85+
{
86+
return [self initWithBundleURLBlock:^{
87+
return bundleURL;
88+
}];
89+
}
90+
8391
@end
8492

8593
@interface RCTRootViewFactory () <RCTCxxBridgeDelegate> {

0 commit comments

Comments
 (0)