PackageGen is command line tool that generates Package.swift files based on Packagefile and package.yml files. It helps to minimize manifest code writing for new modules.
In addition it can render dependencies graph to give you visual representation of your dependencies (see Rendering Dependencies Graph for more info).
This tool is simply allow you to write same Package.swift manifest files in yml and omit some repeating properties by declaring all of them in one place - Packagefile (which is also written in yml). It seems not really useful when your project has few modules, but process of writing whole Package.swift over and over againg can become messy and tedious when your projects grows (with number of modules respectively).
Here is simple comparison between two approaches (note that Packagefile is one for whole project):
Fill Packagefile with all external dependencies and default parameters (swiftToolsVersion, platforms, swiftLanguageVersions etc.) you need (see Packagefile Spec for more info)
Add package.yml (in root of package) for every package you have
Fill package.yml with required parameters. In most cases it’s just module dependencies, but you can also customize any parameters that vanilla Package.swift has (see Manifest Spec for more info)
Run pkgen generate to generate Package.swift for every pacakge
[Optional] add Package.swift to your .gitignore to keep things clear 🙂
Available Commands
pkgen generate
This will look for a Packagefile in the current directory and traverse all subdirectories (excluding hidden directories) in current directory for any package.yml files. For every package.yml found this command will generate Package.swift file next to it.
Options:
-q –quietly - Disable all logs
–use-cache - Generate Package.swift for only modifies package.yml from last generation (or if Packagefile was changed). Cache file will be located at ~/.pkgen/cache/pkgen_cache.json
pkgen graph
This will take provided Packagefile and render graph.pdf to output path.
PackageGen

PackageGen is command line tool that generates
Package.swift
files based onPackagefile
andpackage.yml
files. It helps to minimize manifest code writing for new modules.In addition it can render dependencies graph to give you visual representation of your dependencies (see Rendering Dependencies Graph for more info).
This tool is simply allow you to write same
Package.swift
manifest files in yml and omit some repeating properties by declaring all of them in one place -Packagefile
(which is also written in yml).It seems not really useful when your project has few modules, but process of writing whole
Package.swift
over and over againg can become messy and tedious when your projects grows (with number of modules respectively).Here is simple comparison between two approaches (note that
Packagefile
is one for whole project):Vanilla Package.swift
PackageGen's package.yml
Packagefile
:package.yml
:Installing
From release (recommended)
Homebrew (not supported yet)
Swift Package Manager
Usage
Basically, all you need to do is:
Packagefile
in root of your projectPackagefile
with all external dependencies and default parameters (swiftToolsVersion
,platforms
,swiftLanguageVersions
etc.) you need (see Packagefile Spec for more info)package.yml
(in root of package) for every package you havepackage.yml
with required parameters. In most cases it’s just module dependencies, but you can also customize any parameters that vanillaPackage.swift
has (see Manifest Spec for more info)pkgen generate
to generatePackage.swift
for every pacakgePackage.swift
to your.gitignore
to keep things clear 🙂Available Commands
This will look for a
Packagefile
in the current directory and traverse all subdirectories (excluding hidden directories) in current directory for anypackage.yml
files. For everypackage.yml
found this command will generate Package.swift file next to it.Options:
Package.swift
for only modifiespackage.yml
from last generation (or ifPackagefile
was changed). Cache file will be located at~/.pkgen/cache/pkgen_cache.json
This will take provided
Packagefile
and rendergraph.pdf
to output path.Arguments:
Packagefile
graph.pdf
output fileGet detailed usage information from cli.
Documentation
Contributing
Feel free to make pull requests for any bugs, features, or documentation, they are always welcome!
To contribute to pkgen, follow these steps:
git checkout -b <branch_name>
git commit -m '<commit_message>'
git push origin dev
License
MIT license. See LICENSE for details.