yonaskolb / XcodeGen

A Swift command line tool for generating your Xcode project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

set 'no group' for local packages

MartinP7r opened this issue · comments

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

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
    /Package2

What I want is:

/MyProject
  /Package1
  /Package2

Looking at

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)
}
}
I don't see a way to configure the package's group and localPackagesGroup that doesn't put it in at least one folder.

I don't see an obvious change to the API, other than accepting "" for group or localPackageGroup. 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.

@hiltonc I'm happy with that solution (setting group to "") or allowing options.localPackagesGroup to be "", if you'd like to make a PR

@yonaskolb Thanks, I added support for both options in #1413.

Now we only need someone to review. 🥺

@yonaskolb would you be able to review or assign/recommend someone able to review?