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
This commit is contained in:
Yonas Kolb
2026-03-11 00:44:51 +11:00
committed by GitHub
parent acd366f089
commit 8cfdf30a9f
2 changed files with 26 additions and 1 deletions
+3 -1
View File
@@ -780,7 +780,9 @@ class SourceGenerator {
try makePathRelative(for: sourceReference, at: path)
} else if createIntermediateGroups {
createIntermediaGroups(for: sourceReference, at: sourcePath)
try makePathRelative(for: sourceReference, at: sourcePath)
if type != .folder {
try makePathRelative(for: sourceReference, at: sourcePath)
}
}
return sourceFiles
@@ -968,6 +968,29 @@ class SourceGeneratorTests: XCTestCase {
try pbxProj.expectFileMissing(paths: ["Sources", "A", "a.swift"])
}
$0.it("generates folder references with createIntermediateGroups") {
let directories = """
Sources:
A:
- a.resource
- b.resource
"""
try createDirectories(directories)
let target = Target(name: "Test", type: .application, platform: .iOS, sources: [
TargetSource(path: "Sources/A", type: .folder),
])
let project = Project(
basePath: directoryPath,
name: "Test",
targets: [target],
options: .init(createIntermediateGroups: true)
)
let pbxProj = try project.generatePbxProj()
try pbxProj.expectFile(paths: ["Sources", "Sources/A"], names: ["Sources", "A"], buildPhase: .resources)
}
$0.it("adds files to correct build phase") {
let directories = """
A: