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.swiftfiles based onPackagefileandpackage.ymlfiles. 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.swiftmanifest 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.swiftover 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
Packagefileis 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:
Packagefilein root of your projectPackagefilewith all external dependencies and default parameters (swiftToolsVersion,platforms,swiftLanguageVersionsetc.) you need (see Packagefile Spec for more info)package.yml(in root of package) for every package you havepackage.ymlwith required parameters. In most cases it’s just module dependencies, but you can also customize any parameters that vanillaPackage.swifthas (see Manifest Spec for more info)pkgen generateto generatePackage.swiftfor every pacakgePackage.swiftto your.gitignoreto keep things clear 🙂Available Commands
This will look for a
Packagefilein the current directory and traverse all subdirectories (excluding hidden directories) in current directory for anypackage.ymlfiles. For everypackage.ymlfound this command will generate Package.swift file next to it.Options:
Package.swiftfor only modifiespackage.ymlfrom last generation (or ifPackagefilewas changed). Cache file will be located at~/.pkgen/cache/pkgen_cache.jsonThis will take provided
Packagefileand rendergraph.pdfto output path.Arguments:
Packagefilegraph.pdfoutput 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 devLicense
MIT license. See LICENSE for details.