Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

terminal vapor update is using Swift tools version 3.1.0 which is no longer supported; use 4.0.0 or newer instead\n", output:

Tags:

swift

vapor

leaf

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).

like image 333
askit Avatar asked Dec 27 '19 12:12

askit


2 Answers

A somewhat detailed checklist would be …

  1. Check Swift version. Then, if needed, update Xcode for a recent released Swift version on macOS. In Xcode > Preferences > Locations > Command Line Tools, confirm that the 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
  1. If needed, update and upgrade 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
  1. Check the 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
  1. Now, with the prerequisites in place, install (or reinstall) Vapor 3 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
  1. Verify.
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.

  1. Generate Xcode Project
# still in SomeProjectName terminal working directory
vapor xcode
like image 72
l --marc l Avatar answered Nov 13 '22 10:11

l --marc l


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.

like image 26
askit Avatar answered Nov 13 '22 10:11

askit