From 66e2c6d60270dd3b547de1ac2ef6f562ad752070 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Tue, 6 Jan 2026 12:25:34 -0800 Subject: [PATCH] fix(workspaces): duplicate added frameworks --- lib/services/ios-project-service.ts | 39 ++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index ce078642f3..bfd37bf216 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -545,6 +545,18 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ } } + // Track added frameworks by name to prevent duplicates in monorepo/workspace setups + // where the same plugin may exist in multiple node_modules paths + private _addedFrameworks: Set = new Set(); + + /** + * Clears the framework and static library tracking sets. Should be called at the start of a new prepare cycle. + */ + public clearFrameworksCache(): void { + this._addedFrameworks.clear(); + this._addedStaticLibs.clear(); + } + private async addFramework( frameworkPath: string, projectData: IProjectData, @@ -553,6 +565,16 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ return; } + // Check if framework with same name already added (prevents duplicate output errors in monorepos) + const frameworkName = path.basename(frameworkPath); + if (this._addedFrameworks.has(frameworkName)) { + this.$logger.trace( + `Framework ${frameworkName} already added, skipping duplicate from ${frameworkPath}`, + ); + return; + } + this._addedFrameworks.add(frameworkName); + this.validateFramework(frameworkPath); const project = this.createPbxProj(projectData); @@ -592,12 +614,24 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ this.savePbxProj(project, projectData); } + // Track added static libraries by name to prevent duplicates in monorepo/workspace setups + private _addedStaticLibs: Set = new Set(); + private async addStaticLibrary( staticLibPath: string, projectData: IProjectData, ): Promise { - // Copy files to lib folder. + // Check if static library with same name already added (prevents duplicate errors in monorepos) const libraryName = path.basename(staticLibPath, ".a"); + if (this._addedStaticLibs.has(libraryName)) { + this.$logger.trace( + `Static library ${libraryName} already added, skipping duplicate from ${staticLibPath}`, + ); + return; + } + this._addedStaticLibs.add(libraryName); + + // Copy files to lib folder. const headersSubpath = path.join( path.dirname(staticLibPath), "include", @@ -1157,6 +1191,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ projectData: IProjectData, opts: IRelease, ): Promise { + // Clear framework tracking for fresh duplicate detection + this.clearFrameworksCache(); + const platformData = this.getPlatformData(projectData); const pluginsData = this.getAllProductionPlugins(projectData); this.setProductBundleIdentifier(projectData);