Danger-Swift plugin to show the coverage of the modified/created files.
You can use a "full SPM" solution to install both danger-swift and DangerSwiftCoverage.
- Add to your
Package.swift:
let package = Package(
...
products: [
...
.library(name: "DangerDeps", type: .dynamic, targets: ["DangerDependencies"]), // dev
...
],
dependencies: [
...
// Danger Plugins
.package(url: "https://github.com/f-meloni/danger-swift-coverage", from: "0.1.0") // dev
...
],
targets: [
.target(name: "DangerDependencies", dependencies: ["Danger", "DangerSwiftCoverage"]), // dev
...
]
)- Add the correct import to your
Dangerfile.swift:
import DangerSwiftCoverage
Coverage.xcodeBuildCoverage(.derivedDataFolder("Build"),
minimumCoverage: 50,
excludedTargets: ["DangerSwiftCoverageTests.xctest"])- Create a folder called
DangerDependenciesonSourceswith an empty file inside like Fake.swift - To run
Dangeruseswift run danger-swift command - (Recommended) If you are using SPM to distribute your framework, use Rocket, or similar to comment out all the dev depencencies from your
Package.swift. This prevents the dev dependencies to be downloaded and compiled with your framework.
- Add this to your
Dangerfile.swift
import DangerSwiftCoverage // package: https://github.com/f-meloni/danger-swift-coverage.git
Coverage.xcodeBuildCoverage(.derivedDataFolder("Build"),
minimumCoverage: 50,
excludedTargets: ["DangerSwiftCoverageTests.xctest"])- (Recommended) Cache the
~/.danger-swiftfolder
- Enable "Gather the Coverage" on Xcode
or, on your CI, execute:
xcodebuild test -scheme DangerSwiftCoverage-Package -derivedDataPath Build/ -enableCodeCoverage YESIf you are using the -resultBundlePath parameter on xcodebuild you will need to use:
Coverage.xcodeBuildCoverage(.xcresultBundle("Build/bundlePath.xcresult"),
minimumCoverage: 50,
excludedTargets: ["DangerSwiftCoverageTests.xctest"])
From Swift 5.0 you can gather the coverage from SPM with the --enable-code-coverage=true flag
For SPM coverage add to your Dangerfile:
Coverage.spmCoverage(minimumCoverage: 50)This project is licensed under the terms of the MIT license. See the LICENSE file.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.


