Contents

dfed/swift-package-generator

A command line tool that generates a Package.swift from distributed definition files.

Distributed package definition

Swift Package Manager is quite powerful, but it centralizes your project’s entire definition into a single file. On a project with multiple teams, centralizing the package definition can be problematic organizationally.

swift-package-generator enables distributing your proejct definition over multiple files and then stiching them back together with a single command.

SwiftPackageGenerator scans your project directory for:

  1. PackageDescription.swift files - Contains package configuration arguments like name, platforms, products, dependencies, and targets.
  2. Subpackage.swift files - Contains shared utilities, extensions, and helper functions that can be reused across your package.

Getting Started

Installation

Swift Package Manager

Add SwiftPackageGenerator as a dependency in your Package.swift:

dependencies: [
    .package(url: "https://github.com/dfed/swift-package-generator.git", from: "0.1.0"),
]

Basic Usage

Run the command line tool to generate your Package.swift file:

swift run swift-generate-package

For a documented list of available parameters, run:

swift run swift-generate-package --help

Example Structure

The project has an Example project with a top-level package configuration, a shared utilities file, and two example modules:

MyProject/
├── PackageDescription.swift          # Top-level package configuration
├── Subpackage.swift                  # Shared target utilities
├── features/
   └── FooFeature/
       ├── PackageDescription.swift  # Feature-specific targets
       └── Sources/
└── libraries/
    └── BarLibrary/
        ├── PackageDescription.swift  # Library-specific targets
        └── Sources/

You can run the following command to generate its Package.swift file:

swift run swift-generate-package --root-directory Example/

Contributing

I’m glad you’re interested in swift-package-generator, and I’d love to see where you take it. Please review the contributing guidelines prior to submitting a Pull Request.

Thanks for being part of this journey, and happy packaging!

Package Metadata

Repository: dfed/swift-package-generator

Default branch: main

README: README.md