swiftswift-package-managervaporswiftlint

How to add SwiftLint to Swift Vapor project


I'm trying to add SwiftLint to my Swift Vapor project but had no luck figuring out these errors.

enter image description here

Full Package.swift code:

import PackageDescription

let package = Package(
    name: "VaporApp",
    platforms: [
       .macOS(.v10_15)
    ],
    dependencies: [
        // 💧 A server-side Swift web framework.
        .package(url: "https://github.com/vapor/vapor.git", from: "4.0.0"),
        .package(url: "https://github.com/realm/SwiftLint.git", from: "0.50.3")
    ],
    targets: [
        .target(
            name: "App",
            dependencies: [
                .product(name: "Vapor", package: "vapor")
            ],
            swiftSettings: [
                .unsafeFlags(["-cross-module-optimization"], .when(configuration: .release))
            ],
            plugins: [.plugin(name: "SwiftLintPlugin", package: "SwiftLint")]
        ),
        .target(name: "Run", dependencies: [.target(name: "App")]),
        .testTarget(name: "AppTests", dependencies: [
            .target(name: "App"),
            .product(name: "XCTVapor", package: "vapor"),
        ])
    ]
)

Update: Above errors were fixed after setting swift-tools-version to ^5.6 // swift-tools-version:5.6

But now having another issue. I have tried resetting package caches and upgrading packages. enter image description here


Solution

  • You need to set your tools version in the Package.swift file to at least 5.6