Distinguish development dependencies from library dependencies in package manager?

Could there be a way to specify when a dependency package is required only for development purposes, such as SwiftLint and other tools, but doesn't actually need to be linked in any way into build artifacts, similar to how NPM, Bundler, and Gradle allow?

6 Likes

This is a good idea, but we need to write a proposal for it. And it might tie in with other SwiftPM features which are not designed yet.

In the meanwhile, you can already work with development tools without having them linked into your project:

// swift-tools-version:4.0

import PackageDescription

let package = Package(
    name: "Dummy",
    products: [
        .library(name: "Dummy", targets: ["Dummy"]),
    ],
    dependencies: [
        // Add SwiftLint as a standard dependency
        .package(url: "https://github.com/realm/SwiftLint.git", from: "0.25.1"),
    ],
    targets: [
        .target(name: "TestSPM", dependencies: []),
        .testTarget(name: "DummyTests", dependencies: ["Dummy"]),
    ]
)

And then:

$ swift run swiftlint
1 Like