I'm attempting to run a swift command on a Vapor/Fluent app that in the past has been unproblematic. I'm running swift run App migrate
, which normally updates any migrations. But it's throwing the error that is in the title.
I've looked at the Package file and it's got:
targets: [
.target(
name: "App",
dependencies: [
.product(name: "Vapor", package: "vapor"),
.product(name: "FluentPostgresDriver", package: "fluent-postgres-driver"),
.product(name: "Fluent", package: "fluent"),
.product(name: "Leaf", package: "leaf"),
// .product(name: "SendGrid", package: "sendgrid"),
],
swiftSettings: [
// Enable better optimizations when building in Release configuration. -- Despite the use of
// the `.unsafeFlags` construct required by SwiftPM, this flag is recommended for Release
// builds. See <https://github.com/swift-server/guides#building-for-production> for details.
.unsafeFlags(["-cross-module-optimization"], .when(configuration: .release))
]
),
.target(name: "Run", dependencies: [.target(name: "App")]), // comment what follows
.testTarget(name: "AppTests", dependencies: [
.target(name: "App"),
.product(name: "XCTVapor", package: "vapor"),
])
// to here
]
while the name at the top is something different. I have tried reentering the command with the name set in the package section, and that makes no difference.
I've tried the same thing with multiple other projects that are similar, including ones that haven't been changed for months, and worked before, and I get the same error. Attempting to install Command Line Tools says everything is up to date. And resetting Xcode to the standard path (it was never changed) does nothing...
I'm at a bit of a loss on this one... any answers greatly appreciated.
At some point, it seems the swift tooling changed to expect the executableTargetName
("Run") for what you're running rather than the targetName
("App").
So for your example (and my vapor project which is how I figured this out) instead of running swift run App migrate
, you now need to run swift run Run migrate