Repository navigation
set 'no group' for local packages #1209
Description
Activity
I believe this has similarity to #1118
I would like this behavior as well. Currently the best I can do is put the local packages in a top-level folder, like:
/MyProject /Packages /Package1 /Package2What I want is:
/MyProject /Package1 /Package2Looking at
I don't see a way to configure the package'sXcodeGen/Sources/XcodeGenKit/SourceGenerator.swift
Lines 56 to 88 in 26fc38a
func createLocalPackage(path: Path, group: Path?) throws { var pbxGroup: PBXGroup? if let location = group { let fullLocationPath = project.basePath + location pbxGroup = getGroup(path: fullLocationPath, mergingChildren: [], createIntermediateGroups: true, hasCustomParent: false, isBaseGroup: true) } if localPackageGroup == nil && group == nil { let groupName = project.options.localPackagesGroup ?? "Packages" localPackageGroup = addObject(PBXGroup(sourceTree: .sourceRoot, name: groupName)) rootGroups.insert(localPackageGroup!) } let absolutePath = project.basePath + path.normalize() // Get the local package's relative path from the project root let fileReferencePath = try? absolutePath.relativePath(from: projectDirectory ?? project.basePath).string let fileReference = addObject( PBXFileReference( sourceTree: .sourceRoot, name: absolutePath.lastComponent, lastKnownFileType: "folder", path: fileReferencePath ) ) if let pbxGroup = pbxGroup { pbxGroup.children.append(fileReference) } else { localPackageGroup!.children.append(fileReference) } } groupandlocalPackagesGroupthat doesn't put it in at least one folder.I don't see an obvious change to the API, other than accepting "" for
grouporlocalPackageGroup. I'm not aware of that being a precedent anywhere else in the API though.I'm willing to open a PR to add this capability if we can agree on a config option for it.
Reacted by Martin Pfundmair@hiltonc I'm happy with that solution (setting group to "") or allowing
options.localPackagesGroupto be "", if you'd like to make a PRReacted by Hilton Campbell and Martin Pfundmair@yonaskolb Thanks, I added support for both options in #1413.
Reacted by Martin PfundmairThank you @hiltonc!
Reacted by Hilton Campbell@yonaskolb would you be able to review or assign/recommend someone able to review?
The resolution here (options.localPackagesGroup: "") only relocates the local-package folder reference to the project root - it can't remove it. Local packages still get a dual representation: the XCLocalSwiftPackageReference under Package Dependencies plus a browsable folder PBXFileReference in the navigator. When you add a local package through Xcode's own "Add Package Dependencies… > Add Local", only the Package Dependencies entry is created without a duplicate group inside the main project.
I'd like to propose a new global option to match that behaviour:
options:
createLocalPackageGroups: false # default: true
When false, XcodeGen still emits the XCLocalSwiftPackageReference (Package Dependencies stays populated) but skips creating the folder reference/group for all local packages. Default true keeps current output byte-for-byte, so it's fully backward compatible and a minimal diff - the folder is only created in one place (SourceGenerator.createLocalPackage), so it's a single gated call.I have a working implementation with tests and docs ready to submit as a PR. @yonaskolb would you take this, or would you prefer a different name/shape (e.g. a per-package group: none-style key instead of a global option)?
Reacted by ylorn


Is there a way to set no group for a local package?
At the moment there's the
groupoption for local packages andlocalPackagesGroup, but neither can be set to something that allows a package to sit at the projects root without a group.