Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> = 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,
Expand All @@ -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);
Expand Down Expand Up @@ -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<string> = new Set();

private async addStaticLibrary(
staticLibPath: string,
projectData: IProjectData,
): Promise<void> {
// 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",
Expand Down Expand Up @@ -1157,6 +1191,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
projectData: IProjectData,
opts: IRelease,
): Promise<void> {
// Clear framework tracking for fresh duplicate detection
this.clearFrameworksCache();

const platformData = this.getPlatformData(projectData);
const pluginsData = this.getAllProductionPlugins(projectData);
this.setProductBundleIdentifier(projectData);
Expand Down