Skip to content

Commit dc7e9e2

Browse files
cipolleschifacebook-github-bot
authored andcommitted
Exclude generation of app-defined components from RCTThirdPartyFabricComponentsProvider (#47176)
Summary: Pull Request resolved: #47176 While writing the guide for the New Architecture, we realized that we need to exclude the generation of the Cls function in the RCTThirdPartyFabricComponentsProvider for components defined in the app. This is needed because a component that is defined in the app will have those function defined in the app project. However, the RCTThirdPartyFabricComponentsProvider is generated in Fabric, inside the Pods project. The pod project needs to build in isolation from the app and cocoapods then link the app to the pods project. But the compilation of the pods project fails if one of the symbol needed by the pods lives in the app. By disabling the generation of that function in th RCTThirdPartyFabricComponentsProvider, we can successfully build the app. The downside is that the user needs to register the component manually, but this is not an issue because if they are writing a component in the app space, they have all the information tomanually register it in the AppDelegate ## Changelog [iOS][Fixed] - Do not generate the ComponentCls function in the RCTThirdPartyFabricComponentsProvider for components deined in the app. Reviewed By: cortinico, blakef Differential Revision: D64739896 fbshipit-source-id: 0eca818ea0198532a611377d14a3ff4c95cb5fe3
1 parent ad341e3 commit dc7e9e2

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

packages/react-native/scripts/codegen/generate-artifacts-executor.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,11 +519,22 @@ function rootCodegenTargetNeedsThirdPartyComponentProvider(pkgJson, platform) {
519519
return !pkgJsonIncludesGeneratedCode(pkgJson) && platform === 'ios';
520520
}
521521

522-
function dependencyNeedsThirdPartyComponentProvider(schemaInfo, platform) {
522+
function dependencyNeedsThirdPartyComponentProvider(
523+
schemaInfo,
524+
platform,
525+
appCondegenConfigSpec,
526+
) {
523527
// Filter the react native core library out.
524528
// In the future, core library and third party library should
525529
// use the same way to generate/register the fabric components.
526-
return !isReactNativeCoreLibrary(schemaInfo.library.config.name, platform);
530+
// We also have to filter out the the components defined in the app
531+
// because the RCTThirdPartyComponentProvider is generated inside Fabric,
532+
// which lives in a different target from the app and it has no visibility over
533+
// the symbols defined in the app.
534+
return (
535+
!isReactNativeCoreLibrary(schemaInfo.library.config.name, platform) &&
536+
schemaInfo.library.config.name !== appCondegenConfigSpec
537+
);
527538
}
528539

529540
function mustGenerateNativeCode(includeLibraryPath, schemaInfo) {
@@ -732,8 +743,12 @@ function execute(projectRoot, targetPlatform, baseOutputPath) {
732743
if (
733744
rootCodegenTargetNeedsThirdPartyComponentProvider(pkgJson, platform)
734745
) {
735-
const filteredSchemas = schemaInfos.filter(
736-
dependencyNeedsThirdPartyComponentProvider,
746+
const filteredSchemas = schemaInfos.filter(schemaInfo =>
747+
dependencyNeedsThirdPartyComponentProvider(
748+
schemaInfo,
749+
platform,
750+
pkgJson.codegenConfig?.appCondegenConfigSpec,
751+
),
737752
);
738753
const schemas = filteredSchemas.map(schemaInfo => schemaInfo.schema);
739754
const supportedApplePlatforms = filteredSchemas.map(

0 commit comments

Comments
 (0)