Skip to content

Commit 8cfdf30

Browse files
authored
Fix folder source PBXFileReference path regression with createIntermediateGroups (#1605)
Skip makePathRelative for folder-type sources since they use sourceTree .sourceRoot and need the full project-relative path preserved. The call was inadvertently added for all source types in #1596 but only synced folders (.syncedFolder) need it. Fixes #1603
1 parent acd366f commit 8cfdf30

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Sources/XcodeGenKit/SourceGenerator.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,9 @@ class SourceGenerator {
780780
try makePathRelative(for: sourceReference, at: path)
781781
} else if createIntermediateGroups {
782782
createIntermediaGroups(for: sourceReference, at: sourcePath)
783-
try makePathRelative(for: sourceReference, at: sourcePath)
783+
if type != .folder {
784+
try makePathRelative(for: sourceReference, at: sourcePath)
785+
}
784786
}
785787

786788
return sourceFiles

Tests/XcodeGenKitTests/SourceGeneratorTests.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,29 @@ class SourceGeneratorTests: XCTestCase {
968968
try pbxProj.expectFileMissing(paths: ["Sources", "A", "a.swift"])
969969
}
970970

971+
$0.it("generates folder references with createIntermediateGroups") {
972+
let directories = """
973+
Sources:
974+
A:
975+
- a.resource
976+
- b.resource
977+
"""
978+
try createDirectories(directories)
979+
980+
let target = Target(name: "Test", type: .application, platform: .iOS, sources: [
981+
TargetSource(path: "Sources/A", type: .folder),
982+
])
983+
let project = Project(
984+
basePath: directoryPath,
985+
name: "Test",
986+
targets: [target],
987+
options: .init(createIntermediateGroups: true)
988+
)
989+
990+
let pbxProj = try project.generatePbxProj()
991+
try pbxProj.expectFile(paths: ["Sources", "Sources/A"], names: ["Sources", "A"], buildPhase: .resources)
992+
}
993+
971994
$0.it("adds files to correct build phase") {
972995
let directories = """
973996
A:

0 commit comments

Comments
 (0)