Add Swift Build Tool Plugin for automatic dependency validation#3
Add Swift Build Tool Plugin for automatic dependency validation#3tonyarnold merged 20 commits intomainfrom
Conversation
tonyarnold
commented
Jul 17, 2025
- Implement DependencyAuditPlugin conforming to BuildToolPlugin protocol
- Plugin runs prebuild commands with target-specific analysis and Xcode output
- Update Package.swift with plugin target definition and capability
- Add documentation and examples for plugin usage
- Implement DependencyAuditPlugin conforming to BuildToolPlugin protocol - Plugin runs prebuild commands with target-specific analysis and Xcode output - Update Package.swift with plugin target definition and capability - Add documentation and examples for plugin usage
There was a problem hiding this comment.
Pull Request Overview
This PR adds a Swift Package Manager build tool plugin to automate dependency validation during package and Xcode builds.
- Implements
DependencyAuditPluginconforming toBuildToolPluginto run the audit prebuild - Updates
Package.swiftto declare the plugin product and target - Adds documentation in
README.mdand notes inCHANGELOG.mdfor plugin usage
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| README.md | Added Build Tool Plugin integration documentation |
| Plugins/DependencyAuditPlugin/DependencyAuditPlugin.swift | Implemented plugin that runs a prebuild dependency audit |
| Package.swift | Added plugin product and target definitions |
| CHANGELOG.md | Updated changelog with plugin features and architecture |
| cd "\(context.package.directoryURL.path)" | ||
|
|
||
| # Run dependency audit for specific target | ||
| swift run swift-dependency-audit \\ |
There was a problem hiding this comment.
[nitpick] Invoking the audit tool via swift run can be slower and less robust; consider using the PackagePlugin API (context.tool(named:)) to locate and execute the swift-dependency-audit executable directly.
| swift run swift-dependency-audit \\ | |
| "\(try context.tool(named: "swift-dependency-audit").path)" \\ |
| // Check if target name contains "Test" to identify test targets | ||
| if !target.name.lowercased().contains("test") { |
There was a problem hiding this comment.
[nitpick] Detecting test targets by checking the name substring is brittle; use the target’s type (e.g., TestTarget) or another metadata property to differentiate test and non-test targets.
| // Check if target name contains "Test" to identify test targets | |
| if !target.name.lowercased().contains("test") { | |
| // Check if the target is not a TestTarget to identify non-test targets | |
| if !(target is TestTarget) { |
| // For now, analyze all targets and let the tool itself filter appropriately | ||
| // The tool will skip targets that don't have source directories | ||
| return true |
There was a problem hiding this comment.
[nitpick] Analyzing all targets can lead to unnecessary executions on non-source modules; consider filtering to SourceModuleTarget instances within shouldAnalyzeTarget to reduce overhead.
| // For now, analyze all targets and let the tool itself filter appropriately | |
| // The tool will skip targets that don't have source directories | |
| return true | |
| // Only analyze source-based targets | |
| return target is SourceModuleTarget |
50dc49a to
3c91619
Compare
3c91619 to
3f166c0
Compare
3c783a7 to
ee23c93
Compare
CFAbsoluteTimeGetCurrent is not available on Linux - use Date instead
I think that Claude has gone off on a tangent here
d436010 to
8bba0c9
Compare