https://github.com/dfed/swift-package-generator
A command line tool that generates a Package.swift from distributed definition files
https://github.com/dfed/swift-package-generator
Last synced: 8 months ago
JSON representation
A command line tool that generates a Package.swift from distributed definition files
- Host: GitHub
- URL: https://github.com/dfed/swift-package-generator
- Owner: dfed
- License: mit
- Created: 2022-06-06T16:09:56.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-09-01T05:52:29.000Z (10 months ago)
- Last Synced: 2025-10-04T08:44:06.523Z (8 months ago)
- Language: Swift
- Homepage:
- Size: 64.5 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# swift-package-generator
[](https://github.com/dfed/swift-package-generator/actions?query=workflow%3ACI+branch%3Amain)
[](https://codecov.io/gh/dfed/swift-package-generator)
[](https://spdx.org/licenses/MIT.html)
[](https://swiftpackageindex.com/dfed/swift-package-generator)
[](https://swiftpackageindex.com/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:
```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:
```zsh
swift run swift-generate-package
```
For a documented list of available parameters, run:
```zsh
swift run swift-generate-package --help
```
### Example Structure
The project has an [Example](Example/) project with a [top-level package configuration](Example/PackageDescription.swift), a [shared utilities file](Example/Subpackage.swift), and two [example](Example/features/FooFeature/PackageDescription.swift) [modules](Example/libraries/BarLibrary/PackageDescription.swift):
```
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:
```zsh
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](Contributing.md) prior to submitting a Pull Request.
Thanks for being part of this journey, and happy packaging!