From 12a673daef96ae8b729970d5751601e8b1ae495d Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Wed, 25 Jun 2025 18:48:57 -0400 Subject: [PATCH] Use package name for local package fileref name Otherwise, if you git clone XcodeGen under a different directory name (say `foo`), running `swift test` will result in a diff in `Tests/Fixtures/SPM/SPM.xcodeproj/project.pbxproj` that changes the `PBXFileReference` name from `XcodeGen` to `foo` --- Sources/XcodeGenKit/PBXProjGenerator.swift | 2 +- Sources/XcodeGenKit/SourceGenerator.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index 8dcad5af..4f266c16 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -177,7 +177,7 @@ public class PBXProjGenerator { if !excludeFromProject { addObject(packageReference) - try sourceGenerator.createLocalPackage(path: Path(path), group: group.map { Path($0) }) + try sourceGenerator.createLocalPackage(name: name, path: Path(path), group: group.map { Path($0) }) } } } diff --git a/Sources/XcodeGenKit/SourceGenerator.swift b/Sources/XcodeGenKit/SourceGenerator.swift index e6c9948f..c8f117d3 100644 --- a/Sources/XcodeGenKit/SourceGenerator.swift +++ b/Sources/XcodeGenKit/SourceGenerator.swift @@ -52,7 +52,7 @@ class SourceGenerator { return object } - func createLocalPackage(path: Path, group: Path?) throws { + func createLocalPackage(name: String, path: Path, group: Path?) throws { var parentGroup: String = project.options.localPackagesGroup ?? "Packages" if let group { parentGroup = group.string @@ -66,7 +66,7 @@ class SourceGenerator { let fileReference = addObject( PBXFileReference( sourceTree: .sourceRoot, - name: absolutePath.lastComponent, + name: name, lastKnownFileType: "folder", path: fileReferencePath )