diff --git a/packages/react-native/scripts/codegen/generate-artifacts-executor.js b/packages/react-native/scripts/codegen/generate-artifacts-executor.js index 50717a825e1..bb47205ae4a 100644 --- a/packages/react-native/scripts/codegen/generate-artifacts-executor.js +++ b/packages/react-native/scripts/codegen/generate-artifacts-executor.js @@ -489,11 +489,22 @@ function rootCodegenTargetNeedsThirdPartyComponentProvider(pkgJson, platform) { return !pkgJsonIncludesGeneratedCode(pkgJson) && platform === 'ios'; } -function dependencyNeedsThirdPartyComponentProvider(schemaInfo, platform) { +function dependencyNeedsThirdPartyComponentProvider( + schemaInfo, + platform, + appCondegenConfigSpec, +) { // Filter the react native core library out. // In the future, core library and third party library should // use the same way to generate/register the fabric components. - return !isReactNativeCoreLibrary(schemaInfo.library.config.name, platform); + // We also have to filter out the the components defined in the app + // because the RCTThirdPartyComponentProvider is generated inside Fabric, + // which lives in a different target from the app and it has no visibility over + // the symbols defined in the app. + return ( + !isReactNativeCoreLibrary(schemaInfo.library.config.name, platform) && + schemaInfo.library.config.name !== appCondegenConfigSpec + ); } function mustGenerateNativeCode(includeLibraryPath, schemaInfo) { @@ -704,8 +715,12 @@ function execute(projectRoot, targetPlatform, baseOutputPath) { if ( rootCodegenTargetNeedsThirdPartyComponentProvider(pkgJson, platform) ) { - const filteredSchemas = schemaInfos.filter( - dependencyNeedsThirdPartyComponentProvider, + const filteredSchemas = schemaInfos.filter(schemaInfo => + dependencyNeedsThirdPartyComponentProvider( + schemaInfo, + platform, + pkgJson.codegenConfig?.appCondegenConfigSpec, + ), ); const schemas = filteredSchemas.map(schemaInfo => schemaInfo.schema); const supportedApplePlatforms = filteredSchemas.map(