Top Level Files

So I have been working more and more with the SwiftPM and updating both personal and work projects to use it. Lately I’ve seen quite a few pitches that rely on every SomeSwiftPackageManagerConfigFile.swift to be a top level file in a project. I was thinking it might be helpful to keep things organized if there was a way to use a directory to contain the support files that are likely going to become part of the package manager at some point.

My thought being that then a Package.swift or maybe Workspace.swift (if such a file comes to exist) can optionally be the only allowed top file that is part of the build system with the rest nested below.

I think it should be similar to the pkgConfig property of a Package in its usage. The naming here is configDirectory just for simplicity, I don’t imagine it is a good name in the long term.

let package = Package(
    name: "Example",
    configDirectory: "SwiftPMConfig/",
    products: ...
)

/cc @Aciid

I think it would make sense to nest things under a config directory if we’re going to add a lot of config-based files. I doubt we need to add a new API right now without having proper use-cases to back that.

I hope we just don’t need a lot of config files in the first place. That seems like a design direction that would be undesirable for reasons beyond cluttering up the top level.

4 Likes