From a27a25e76f718416afab4acd9f3fbb3ee954adff Mon Sep 17 00:00:00 2001 From: Brandon Kase Date: Thu, 9 Nov 2017 14:53:10 -0800 Subject: [PATCH] Fix duplicate sources in groups, fixes #141 --- Fixtures/TestProject/Project.xcodeproj/project.pbxproj | 10 ---------- Sources/XcodeGenKit/PBXProjGenerator.swift | 3 ++- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/Fixtures/TestProject/Project.xcodeproj/project.pbxproj b/Fixtures/TestProject/Project.xcodeproj/project.pbxproj index 0a048bee..46d61407 100644 --- a/Fixtures/TestProject/Project.xcodeproj/project.pbxproj +++ b/Fixtures/TestProject/Project.xcodeproj/project.pbxproj @@ -180,7 +180,6 @@ isa = PBXGroup; children = ( FR8488480101 /* MoreUnder.swift */, - FR8488480101 /* MoreUnder.swift */, ); name = UnderFileGroup; path = UnderFileGroup; @@ -192,15 +191,6 @@ FR7078510801 /* FrameworkFile.swift */, FR1345298503 /* Info.plist */, FR7740960501 /* MyFramework.h */, - FR7078510801 /* FrameworkFile.swift */, - FR1345298503 /* Info.plist */, - FR7740960501 /* MyFramework.h */, - FR7078510801 /* FrameworkFile.swift */, - FR1345298503 /* Info.plist */, - FR7740960501 /* MyFramework.h */, - FR7078510801 /* FrameworkFile.swift */, - FR1345298503 /* Info.plist */, - FR7740960501 /* MyFramework.h */, ); name = Framework; path = Framework; diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index 9967a1df..82aefc7f 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -504,7 +504,8 @@ public class PBXProjGenerator { func getSingleGroup(path: Path, mergingChildren children: [String], depth: Int = 0) -> PBXGroup { let group: PBXGroup if let cachedGroup = groupsByPath[path] { - cachedGroup.children += children + // only add the children, that aren't already in the cachedGroup + cachedGroup.children += children.filter{ !cachedGroup.children.contains($0) } group = cachedGroup } else { group = PBXGroup(