我在做教程时遇到此错误。我无法解决问题。因此,我删除了该项目,并制作了一个新的简单项目来解决问题,但仍然遇到相同的问题。我正在发布相关代码-
package.swift代码-
// swift-tools-version:4.0
import PackageDescription
let package = Package(
name: "dep",
products: [
.library(name: "dep", targets: ["App"]),
],
dependencies: [
// ? A server-side Swift web framework.
.package(url: "https://github.com/vapor/vapor.git", from: "3.0.0"),
// ? Swift ORM (queries, models, relations, etc) built on SQLite 3.
.package(url: "https://github.com/vapor/fluent-sqlite.git", from: "3.0.0"),
.package(url: "https://github.com/vapor/leaf.git", from: "3.0.0"),
],
targets: [
.target(name: "App", dependencies: ["Leaf","FluentSQLite", "Vapor"]),
.target(name: "Run", dependencies: ["App"]),
.testTarget(name: "AppTests", dependencies: ["App"])
]
)
当我在终端中执行“蒸气构建”并按Enter键时,终端显示错误-“” / Users / apple / dep:错误:打包在\'/ Users / apple / dep \ '正在使用不再支持的Swift工具版本3.1.0;使用4.0.0或更高版本\ n“,输出:”“)”
我已经完成了通常的工作,例如清理构建文件夹,清理派生数据等。 现在,我下一步该怎么做。如果您需要其他任何信息,我可以发布代码或屏幕截图。
答案 0 :(得分:4)
除了l-marc-l发布的答案外,我要尝试的第一步是删除“ // swift-tools-version:4.0”行上方的空行,即package.swift中的第一行,它可以轻松解决我的问题。如果那不能解决问题,那么我将走l --marc l提到的步骤。
答案 1 :(得分:1)
一个比较详细的清单是……
Command Line Tools:
指向当前工具链版本。 Xcode 11.3(11C29)提供了Swift 5.1。swift --version
# Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)
# Target: x86_64-apple-darwin18.7.0
brew
更新并升级到最新版本。 (或者,如果尚未安装Homebrew软件包管理器,请参见https://brew.sh/。)brew --version
# Homebrew 2.2.2
# Homebrew/homebrew-core (git revision dc049; last commit 2019-12-28)
brew update
brew upgrade # Note: upgrade all brew installed formulas.
#brew upgrade FORMULA # use only update one formula
vapor/tap
点击。 (可选)可以将水龙头卸下并重新安装。brew tap # list existing taps
# homebrew/core
# vapor/tap
brew untap vapor/tap
# Untapping vapor/tap...
# Untapped 7 formulae (148 files, 69.8KB).
brew tap --full vapor/tap
vapor
安装(或重新安装)Vapor 3 brew
。蒸气4 Beta vapor-beta
具有github issue。# if vapor has not been installed, then `install`
brew install vapor # Vapor 3
brew install vapor/tap/vapor # same as above. path specified formula.
#brew install vapor-beta # Vapor 4 Beta
# if vapor is already installed, the `reinstall`
brew reinstall vapor
swift --version
# Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)
# Target: x86_64-apple-darwin18.7.0
vapor --version
# Vapor Toolbox: 3.1.10 .... wait, what?
brew info vapor
# vapor/tap/vapor: stable 3.1.12
# https://vapor.codes
# /usr/local/Cellar/vapor/3.1.12 (6 files, 17.8MB) *
# Built from source on 2019-12-28 at 12:46:27
# From: https://github.com/vapor/homebrew-tap/blob/master/vapor.rb
# try
vapor new SomeProjectName --template=api # or, --template=web
cd SomeProjectName
vapor build
# No .build folder, fetch may take a while...
# Fetching Dependencies [Done]
# Building Project [Done]
哦,蒸气工具箱3.1.12声称是“ 3.1.10”。请参阅GitHub问题https://github.com/vapor/toolbox/issues/292。
# still in SomeProjectName terminal working directory
vapor xcode
答案 2 :(得分:0)
您需要更新工具箱(brew upgrade vapor
)或仅运行swift build