Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add codegen ios.componentProvider #2572

Merged
merged 1 commit into from
Dec 10, 2024
Merged

Conversation

jakex7
Copy link
Member

@jakex7 jakex7 commented Dec 9, 2024

Summary

Add a newly introduced field ios.componentProvider to the codegen configuration to create an association map between JS components and their native implementations.

When this field is defined, it is used and codegen don't crawl the file system looking for the mapping. You can find the documentation for it here: https://github.com/facebook/react-native-website/pull/4388/files#diff-7fbb6ff2e58f8bd50d2763e551c63e1816adb6d593f40d489785b575b0e82718R76

Test Plan

Running pod install in the tests-example will currently hang and eventually crash, as it attempts to crawl through the entire repository.

@jakex7 jakex7 marked this pull request as ready for review December 10, 2024 10:24
@jakex7 jakex7 merged commit bf1c32d into main Dec 10, 2024
8 of 11 checks passed
@jakex7 jakex7 deleted the @jakex7/componentProvider branch December 10, 2024 16:03
j-piasecki pushed a commit to software-mansion/react-native-gesture-handler that referenced this pull request Dec 13, 2024
## Description

* 54710a6 - Added `sourceSets` to the
package due to changes in ViewManager function signatures, which are no
longer nullable
* a20adca - Updated to reflect changes
in facebook/react-native#47551,
`findHostInstance_DEPRECATED` is now a property of the `default` object
instead of being a named export. Modified implementation reads from
default and fall back to named export as needed
* ac7e786 - Similar change to the
software-mansion/react-native-svg#2572 that uses
new API to create an association map between JS components and their
native implementations, avoiding `codegen` crawling through the entire
filesystem for `.mm` files.

## Test plan

App with React Native 0.77 (like
#3277)
should compile and work as expected.
kkafar pushed a commit to software-mansion/react-native-screens that referenced this pull request Dec 16, 2024
## Description

Add a newly introduced field `ios.componentProvider` to the `codegen`
configuration to create an association map between JS components and
their native implementations.

See more information here:
software-mansion/react-native-svg#2572

## Changes

- added `codegenConfig.ios.componentProvider` field to package.json

### Before

```objc

Class<RCTComponentViewProtocol> RCTThirdPartyFabricComponentsProvider(const char *name) {
  static std::unordered_map<std::string, Class (*)(void)> sFabricComponentsClassMap = {
    // ...
    {"RNSFullWindowOverlay", RNSFullWindowOverlayCls}, // 3
    {"RNSModalScreen", RNSModalScreenCls}, // 3
    {"RNSScreenContainer", RNSScreenContainerCls}, // 3
    {"RNSScreenContentWrapper", RNSScreenContentWrapperCls}, // 3
    {"RNSScreenFooter", RNSScreenFooterCls}, // 3
    {"RNSScreen", RNSScreenCls}, // 3
    {"RNSScreenNavigationContainer", RNSScreenNavigationContainerCls}, // 3
    {"RNSScreenStackHeaderConfig", RNSScreenStackHeaderConfigCls}, // 3
    {"RNSScreenStackHeaderSubview", RNSScreenStackHeaderSubviewCls}, // 3
    {"RNSScreenStack", RNSScreenStackCls}, // 3
    {"RNSSearchBar", RNSSearchBarCls}, // 3
    // ...
```
### After

```objc
@implementation RCTThirdPartyComponentsProvider

+ (NSDictionary<NSString *, Class<RCTComponentViewProtocol>> *)thirdPartyFabricComponents
{
  return @{
		@"RNSFullWindowOverlay": NSClassFromString(@"RNSFullWindowOverlay"), // react-native-screens
		@"RNSModalScreen": NSClassFromString(@"RNSModalScreen"), // react-native-screens
		@"RNSScreenContainer": NSClassFromString(@"RNSScreenContainer"), // react-native-screens
		@"RNSScreenContentWrapper": NSClassFromString(@"RNSScreenContentWrapper"), // react-native-screens
		@"RNSScreenFooter": NSClassFromString(@"RNSScreenFooter"), // react-native-screens
		@"RNSScreen": NSClassFromString(@"RNSScreen"), // react-native-screens
		@"RNSScreenNavigationContainer": NSClassFromString(@"RNSScreenNavigationContainer"), // react-native-screens
		@"RNSScreenStackHeaderConfig": NSClassFromString(@"RNSScreenStackHeaderConfig"), // react-native-screens
		@"RNSScreenStackHeaderSubview": NSClassFromString(@"RNSScreenStackHeaderSubview"), // react-native-screens
		@"RNSScreenStack": NSClassFromString(@"RNSScreenStack"), // react-native-screens
		@"RNSSearchBar": NSClassFromString(@"RNSSearchBar"), // react-native-screens
  };
}
```

## Test code and steps to reproduce

Run `pod install` in React Native 0.77 app and see
`RCTThirdPartyFabricComponentsProvider` to check the content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant