mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2024-09-11 12:56:03 +03:00
Merge pull request #217 from allu22/duplicate-source-ref
Filter out duplicate file references from sources build phase
This commit is contained in:
commit
2338b47d84
@ -408,6 +408,11 @@ public class PBXProjGenerator {
|
||||
func getBuildFilesForPhase(_ buildPhase: BuildPhase) -> [String] {
|
||||
let files = sourceFiles
|
||||
.filter { $0.buildPhase == buildPhase }
|
||||
.reduce(into: [SourceFile]()) { (output, sourceFile) in
|
||||
if !output.contains(where: { $0.fileReference == sourceFile.fileReference }) {
|
||||
output.append(sourceFile)
|
||||
}
|
||||
}
|
||||
.sorted { $0.path.lastComponent < $1.path.lastComponent }
|
||||
files.forEach { addObject($0.buildFile) }
|
||||
return files.map { $0.buildFile.reference }
|
||||
|
@ -744,6 +744,31 @@ func projectGeneratorTests() {
|
||||
try project.expectFile(paths: ["C", "file.123"], buildPhase: .resources)
|
||||
try project.expectFile(paths: ["C", "Info.plist"], buildPhase: .none)
|
||||
}
|
||||
|
||||
|
||||
$0.it("duplicate TargetSource is included once in sources build phase") {
|
||||
let directories = """
|
||||
Sources:
|
||||
A:
|
||||
- a.swift
|
||||
"""
|
||||
try createDirectories(directories)
|
||||
|
||||
let target = Target(name: "Test", type: .application, platform: .iOS, sources: [
|
||||
"Sources/A/a.swift",
|
||||
"Sources/A/a.swift",
|
||||
])
|
||||
let spec = ProjectSpec(basePath: directoryPath, name: "Test", targets: [target])
|
||||
|
||||
let project = try getPbxProj(spec)
|
||||
try project.expectFile(paths: ["Sources/A", "a.swift"], names: ["A", "a.swift"], buildPhase: .sources)
|
||||
|
||||
let sourcesBuildPhase = project.objects.buildPhases
|
||||
.first(where: { $0.1.buildPhase == BuildPhase.sources })!
|
||||
.value
|
||||
|
||||
try expect(sourcesBuildPhase.files.count) == 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user