-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate
RCTAppDependencyProvider
for apps (#47650)
Summary: Pull Request resolved: #47650 ## This Change: This change generates the `RCTAppDependencyProvider` for the apps, so that the amount of changes required by the users is minimal. ## Context React Native has a last temporal dependency on Codegen in the React-RCTAppDelegate pod. The RCTAppDelegate has the responsibility to provide various dependencies to react native, like third party components and various modules. ReactCodegen is generated when the user create the project, while React-RCTAppDelegate eists in React Native itself. This dependency means that we cannot prepare prebuilt for iOS for React Native because when we would have to create prebuilds, we would need the React Codegen, but we can't create a React codegen package that will fit all the apps, because React Codegen can contains App Specific modules and components and apps might have different dependencies. ## Changelog: [iOS][Added] - Introduce the RCTAppDependencyProvider to minimize the changes required y the users Reviewed By: dmytrorykun Differential Revision: D66074456 fbshipit-source-id: 073022e66da53eca6bf948aeda01f17ad85793ff
- Loading branch information
1 parent
b91626a
commit 41c2502
Showing
4 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/react-native/scripts/codegen/templates/RCTAppDependencyProviderH.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#if __has_include(<React-RCTAppDelegate/RCTDependencyProvider.h>) | ||
#import <React-RCTAppDelegate/RCTDependencyProvider.h> | ||
#elif __has_include(<React_RCTAppDelegate/RCTDependencyProvider.h>) | ||
#import <React_RCTAppDelegate/RCTDependencyProvider.h> | ||
#else | ||
#import "RCTDependencyProvider.h" | ||
#endif | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface RCTAppDependencyProvider : NSObject <RCTDependencyProvider> | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
55 changes: 55 additions & 0 deletions
55
packages/react-native/scripts/codegen/templates/RCTAppDependencyProviderMM.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import "RCTAppDependencyProvider.h" | ||
#import "RCTModulesConformingToProtocolsProvider.h" | ||
#import "RCTThirdPartyComponentsProvider.h" | ||
|
||
@implementation RCTAppDependencyProvider { | ||
NSArray<NSString *> * _URLRequestHandlerClassNames; | ||
NSArray<NSString *> * _imageDataDecoderClassNames; | ||
NSArray<NSString *> * _imageURLLoaderClassNames; | ||
NSDictionary<NSString *,Class<RCTComponentViewProtocol>> * _thirdPartyFabricComponents; | ||
} | ||
|
||
- (nonnull NSArray<NSString *> *)URLRequestHandlerClassNames { | ||
static dispatch_once_t requestUrlToken; | ||
dispatch_once(&requestUrlToken, ^{ | ||
self->_URLRequestHandlerClassNames = RCTModulesConformingToProtocolsProvider.URLRequestHandlerClassNames; | ||
}); | ||
|
||
return _URLRequestHandlerClassNames; | ||
} | ||
|
||
- (nonnull NSArray<NSString *> *)imageDataDecoderClassNames { | ||
static dispatch_once_t dataDecoderToken; | ||
dispatch_once(&dataDecoderToken, ^{ | ||
_imageDataDecoderClassNames = RCTModulesConformingToProtocolsProvider.imageDataDecoderClassNames; | ||
}); | ||
|
||
return _imageDataDecoderClassNames; | ||
} | ||
|
||
- (nonnull NSArray<NSString *> *)imageURLLoaderClassNames { | ||
static dispatch_once_t urlLoaderToken; | ||
dispatch_once(&urlLoaderToken, ^{ | ||
_imageURLLoaderClassNames = RCTModulesConformingToProtocolsProvider.imageURLLoaderClassNames; | ||
}); | ||
|
||
return _imageURLLoaderClassNames; | ||
} | ||
|
||
- (nonnull NSDictionary<NSString *,Class<RCTComponentViewProtocol>> *)thirdPartyFabricComponents { | ||
static dispatch_once_t nativeComponentsToken; | ||
dispatch_once(&nativeComponentsToken, ^{ | ||
_thirdPartyFabricComponents = RCTThirdPartyComponentsProvider.thirdPartyFabricComponents; | ||
}); | ||
|
||
return _thirdPartyFabricComponents; | ||
} | ||
|
||
@end |