The Swift-TargetDependencyGraph plugin is a Swift Package Manager command plugin that supports generating a diagram of target dependencies with Graphviz.
- Swift 5.6+
- Graphviz installed and available in your PATH
Add the package to your dependencies.
let package = Package(
// name, platforms, products, etc.
dependencies: [
// other dependencies
.package(url: "https://github.com/mobelux/swift-dependency-graph-plugin", from: "1.0.0"),
],
targets: [
// targets
]
)
Create a diagram of a target's dependencies:
swift package --allow-writing-to-package-directory dependency-graph
You can specify targets to exclude by adding --exclude <excluded targets>
- This plugin was inspired by Yusuke KUROIWA's generate-target-dependencies.sh shell script
- Marco Eidinger's posts and his SwiftFormatPlugin offered a lot of guidance for implementing command plugins
- The GraphViz models were inspired by the GraphViz package