swift Vapor:无法从命令行迁移/恢复

bjp0bcyl  于 2024-01-05  发布在  Swift
关注(0)|答案(1)|浏览(163)

我尝试从命令行运行Vapor应用程序的迁移。基本命令swift run App似乎不起作用。下面是一个典型的测试,比较旧的语法。

  1. danieldonaldson@Daniels-Mac-mini wb2-web % vapor run migrate
  2. This command is deprecated. Use `swift run App` instead.
  3. Error: Invalid URL: /Volumes/500 GB Current/Current Work/wb2-web/Package.swift
  4. danieldonaldson@Daniels-Mac-mini wb2-web % swift run App migrate
  5. error: no executable product named 'App'

字符串
Package.swift文件位于Active Directory中,并且似乎使用名称“App”。

  1. targets: [
  2. .target(
  3. name: "App",
  4. dependencies: [
  5. .product(name: "Vapor", package: "vapor"),
  6. .product(name: "FluentPostgresDriver", package: "fluent-postgres-driver"),
  7. .product(name: "Fluent", package: "fluent"),
  8. .product(name: "Leaf", package: "leaf"),
  9. // .product(name: "SendGrid", package: "sendgrid"),
  10. ],
  11. swiftSettings: [
  12. // Enable better optimizations when building in Release configuration. -- Despite the use of
  13. // the `.unsafeFlags` construct required by SwiftPM, this flag is recommended for Release
  14. // builds. See <https://github.com/swift-server/guides#building-for-production> for details.
  15. .unsafeFlags(["-cross-module-optimization"], .when(configuration: .release))
  16. ]
  17. ),


虽然在顶部,名称是不同的:

  1. let package = Package(
  2. name: "Authentication",
  3. platforms: [
  4. .macOS(.v10_15)
  5. ],


但这是一个已经在几年的地方的名称,没有变化已作出.我不通常迁移或恢复手动,但在这种情况下,我必须测试一些东西.所以我不知道什么时候突然出现,但我确实需要检查这个.
为什么swift找不到应用程序的可执行文件?我相信这是相当标准的Vapor做法。

lfapxunr

lfapxunr1#

在Package.swift中,您有一个.target和一个.executableTarget. Recent Vapor 4版本a,它查看的是executableTarget名称,而不是target名称。很可能您的executableTarget名称是'Run',因此只需使用

  1. swift run Run

字符串

相关问题