Skip to content

Commit 66e2c6d

Browse files
committed
fix(workspaces): duplicate added frameworks
1 parent b5dd689 commit 66e2c6d

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

lib/services/ios-project-service.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,18 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
545545
}
546546
}
547547

548+
// Track added frameworks by name to prevent duplicates in monorepo/workspace setups
549+
// where the same plugin may exist in multiple node_modules paths
550+
private _addedFrameworks: Set<string> = new Set();
551+
552+
/**
553+
* Clears the framework and static library tracking sets. Should be called at the start of a new prepare cycle.
554+
*/
555+
public clearFrameworksCache(): void {
556+
this._addedFrameworks.clear();
557+
this._addedStaticLibs.clear();
558+
}
559+
548560
private async addFramework(
549561
frameworkPath: string,
550562
projectData: IProjectData,
@@ -553,6 +565,16 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
553565
return;
554566
}
555567

568+
// Check if framework with same name already added (prevents duplicate output errors in monorepos)
569+
const frameworkName = path.basename(frameworkPath);
570+
if (this._addedFrameworks.has(frameworkName)) {
571+
this.$logger.trace(
572+
`Framework ${frameworkName} already added, skipping duplicate from ${frameworkPath}`,
573+
);
574+
return;
575+
}
576+
this._addedFrameworks.add(frameworkName);
577+
556578
this.validateFramework(frameworkPath);
557579

558580
const project = this.createPbxProj(projectData);
@@ -592,12 +614,24 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
592614
this.savePbxProj(project, projectData);
593615
}
594616

617+
// Track added static libraries by name to prevent duplicates in monorepo/workspace setups
618+
private _addedStaticLibs: Set<string> = new Set();
619+
595620
private async addStaticLibrary(
596621
staticLibPath: string,
597622
projectData: IProjectData,
598623
): Promise<void> {
599-
// Copy files to lib folder.
624+
// Check if static library with same name already added (prevents duplicate errors in monorepos)
600625
const libraryName = path.basename(staticLibPath, ".a");
626+
if (this._addedStaticLibs.has(libraryName)) {
627+
this.$logger.trace(
628+
`Static library ${libraryName} already added, skipping duplicate from ${staticLibPath}`,
629+
);
630+
return;
631+
}
632+
this._addedStaticLibs.add(libraryName);
633+
634+
// Copy files to lib folder.
601635
const headersSubpath = path.join(
602636
path.dirname(staticLibPath),
603637
"include",
@@ -1157,6 +1191,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
11571191
projectData: IProjectData,
11581192
opts: IRelease,
11591193
): Promise<void> {
1194+
// Clear framework tracking for fresh duplicate detection
1195+
this.clearFrameworksCache();
1196+
11601197
const platformData = this.getPlatformData(projectData);
11611198
const pluginsData = this.getAllProductionPlugins(projectData);
11621199
this.setProductBundleIdentifier(projectData);

0 commit comments

Comments
 (0)