I have the following Package.swift:
// swift-tools-version:5.2
import PackageDescription
let package = Package(
name: "my-vapor-project",
platforms: [
.macOS(.v10_15)
],
dependencies: [
// 💧 A server-side Swift web framework.
.package(url: "https://github.com/vapor/vapor.git", from: "4.0.0-rc"),
.package(url: "https://github.com/vapor/fluent.git", from: "4.0.0-rc"),
.package(url: "https://github.com/vapor/fluent-mysql-driver.git", from: "4.0.0-rc"),
.package(url: "https://github.com/apple/swift-package-manager", .branch("master")),
],
targets: [
.target(name: "App", dependencies: [
.product(name: "Fluent", package: "fluent"),
.product(name: "FluentMySQLDriver", package: "fluent-mysql-driver"),
.product(name: "Vapor", package: "vapor"),
.product(name: "SwiftPM", package: "swift-package-manager")
]),
.target(name: "Run", dependencies: ["App"]),
.testTarget(name: "AppTests", dependencies: [
.target(name: "App"),
.product(name: "XCTVapor", package: "vapor"),
])
]
)
When I save the file, Xcode attempts to resolve the dependencies automatically, and I get the following error and warning:
Showing All Messages /Users/sluther/Projects/my-vapor-project/Package.swift: product dependency 'SwiftPM' in package 'swift-package-manager' not found
: dependency 'SwiftPM' is not used by any target
It turns out that at the time of writing, Swift Package Manager could not be included as a dependency when using Swift Tools Version 5.2 which removed the old syntax for defining Product dependencies. Switching the Swift Tools Version to 5.1 resolved the issue.
// swift-tools-version:5.1
import PackageDescription
let package = Package(
name: "my-vapor-project",
platforms: [
.macOS(.v10_15)
],
dependencies: [
// 💧 A server-side Swift web framework.
.package(url: "https://github.com/vapor/vapor.git", from: "4.0.0-rc"),
.package(url: "https://github.com/vapor/fluent.git", from: "4.0.0-rc"),
.package(url: "https://github.com/vapor/fluent-mysql-driver.git", from: "4.0.0-rc"),
.package(url: "https://github.com/apple/swift-package-manager", .branch("master")),
],
targets: [
.target(name: "App", dependencies: [
.product(name: "Fluent", package: "fluent"),
.product(name: "FluentMySQLDriver", package: "fluent-mysql-driver"),
.product(name: "Vapor", package: "vapor"),
"SwiftPM"
]),
.target(name: "Run", dependencies: ["App"]),
.testTarget(name: "AppTests", dependencies: [
.target(name: "App"),
.product(name: "XCTVapor", package: "vapor"),
])
]
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With