0

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

Wendell
  • 474
  • 3
  • 12

1 Answers1

2

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

0xTim
  • 5,146
  • 11
  • 23
  • Thanks! That fixed it. But now I'm having another issue: – Wendell Mar 09 '23 at 23:08
  • Failed to resolve dependencies Dependencies could not be resolved because root depends on 'swiftlint' 0.50.3..<1.0.0. 'swiftlint' >= 0.50.3 cannot be used because no versions of 'swiftlint' match the requirement 0.50.4..<1.0.0 and package 'swiftlint' is required using a stable-version but 'swiftlint' depends on an unstable-version package 'swift-syntax'. – Wendell Mar 09 '23 at 23:08
  • Thanks! But now I have another issue... – Wendell Mar 09 '23 at 23:09
  • Try running `swift package update` – 0xTim Mar 11 '23 at 18:58
  • Tried, didn't work. – Wendell Mar 11 '23 at 23:11
  • Only thing I can think of is deleting the Package.resolved then and maybe the SwiftPM cache – 0xTim Mar 14 '23 at 09:49
  • 1
    Somehow I fixed this issue by using ```package(url: "https://github.com/realm/SwiftLint", branch: "main")``` – Wendell Mar 15 '23 at 01:05