I had this error when I was doing a tutorial. I could not solve the problem. So, I deleted the project and made a new simple project to figure-out the issue,but still having the same issue. I am posting relevant code -
package.swift code -
// 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"])
]
)
When I do "vapor build" in terminal and press enter, the terminal shows error - " "/Users/apple/dep: error: package at \'/Users/apple/dep\' is using Swift tools version 3.1.0 which is no longer supported; use 4.0.0 or newer instead\n", output: "")"
I have done the usual stuff like clean-build folder, cleaning derived data etc. Now, what should I do next. If you need any further information, I can post code(s) or screenshot(s).
A somewhat detailed checklist would be …
Command Line Tools:
is pointing to current toolchain version. Xcode 11.3 (11C29) provides 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
to the most recent version. (Or, see https://brew.sh/ if the Homebrew package manager is not yet installed.)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
tap. Optionally, the tap can be removed and installed again.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
via brew
. Vapor 4 beta vapor-beta
has a 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]
Oh, Vapor Toolbox 3.1.12 claims to be "3.1.10". See GitHub issue https://github.com/vapor/toolbox/issues/292.
# still in SomeProjectName terminal working directory
vapor xcode
In addition to the answer posted by l-marc-l , the first step I had to try was to remove the empty line above "// swift-tools-version:4.0" line i.e. the first line in package.swift, it could have easily sorted my issue. If that would not have sorted the issue, then I would have gone for the steps mentioned by l --marc l.
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