Error on swift tool version

Hi there,

I'm confused about this strange problem I'm facing.

I'm running a Mac with High Sierra (10.13.60) and Xcode 9.4.1.

I've started a new Swift project with: swift package init --type executable

I can see the project in Xcode and I'm aware that I can't run it from there because Xcode's lack of Package.swift support.

But whenever I would like to run the project with the Swift CLI I get this error:

Package requires minimum Swift tools version 4.0.0. Current Swift tools version is 3.1.0

I've looked in many places but I can't find a link to a recent version of the Swift tools.

Any thoughts on how I can upgrade my Mac to the latest level of Swift tools?

Many thanks!

__Frank

Maybe you have an older Xcode selected on the command-line? You can select the 9.4.1 using:

sudo xcode-select -s /path/to/Xcode.app

You can verify that you're using Swift 4 using swift -version command.

Hi Aclid, thanks for the reply...

Well, I've solved it with help of your hint, but it was not that straightforward ...

I looked into the path to Xcode but I could find any other version available. I uninstalled Xcode and re-installed, same issue.
I then renamed the /usr/bin/swift exec to see if that helped, but strangely no help here as well.

I deleted in Xcode the Swift 3.1.1 entries

After entering swift --version the reply was then:

swiftenv: version `3.1.1' (set by /Users/thewall/.swiftenv/version) is not installed

That hinted me to that path and there was a file named version (with only 3.1.1 as text in it). I renamed that file and issued swift --version again:

Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0

EUREKA!

So, it boiled down to the fact that there is a version file in /Users//.swiftenv/ called version and that holds the info on what version it has.

Hope this entry helps other to explore swift...

Cheers, Frank