diff --git a/packages/react-native/scripts/codegen/generate-artifacts-executor.js b/packages/react-native/scripts/codegen/generate-artifacts-executor.js index 8e89bf0007ffb7..d9af18b0806b8b 100644 --- a/packages/react-native/scripts/codegen/generate-artifacts-executor.js +++ b/packages/react-native/scripts/codegen/generate-artifacts-executor.js @@ -519,11 +519,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) { @@ -732,8 +743,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(