Unable to set swift version

Hi,I am newbie swift learner and was trying to install swift environment. I am stuck and I would appreciate your help. I have Xcode 13.0 and swift 5.5 installed.

Here is what I did to install swift environment:
1)git clone GitHub - kylef/swiftenv: Swift Version Manager ~/.swiftenv
2)nano ~/.bash_profile
everything was empty there so I wrote as follows:
#swiftenv

export SWIFTENV_ROOT="$HOME/.swiftenv"

export PATH="$SWIFTENV_ROOT/BIN:$PATH"

eval "$(swiftenv init -)"
Then I saved it.
3)wrote ~./bash_profile
4)swiftenv
5)swift versions

got an error:
error: unable to invoke subcommand: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-versions (No such file or directory)
6) for once I ignored this and wrote: cd /Library/Developer/Toolchains
7)pwd
8) ls-la
9)I got
total 0
drwxr-xr-x 4 root wheel 128 Oct 19 20:45 .
drwxr-xr-x 4 root admin 128 Oct 19 20:45 ..
drwxr-xr-x 7 root wheel 224 Oct 19 20:45 swift-5.5-RELEASE.xctoolchain
lrwxr-xr-x 1 root wheel 59 Oct 19 20:45 swift-latest.xctoolchain -> /Library/Developer/Toolchains/swift-5.5-RELEASE.xctoolchain
10) cd ~/Desktop/
11)swiftenv global
zsh displayed: swiftenv: version is not set

Now,Here at this point I felt there is something wrong.

Modern macOS systems use zsh, not bash, as the default shell, so you'll need to modify the appropriate files for that shell (~/.zprofile) or switch to bash.

1 Like

Thanks for your help Sir, I tried and it's giving me error again.

In bash profile page I pasted this:
echo 'export SWIFTENV_ROOT="$HOME/.swiftenv"' >> ~/.zshenv
echo 'export PATH="$SWIFTENV_ROOT/bin:$PATH"' >> ~/.zshenv
echo 'eval "$(swiftenv init -)"' >> ~/.zshenv

You're more likely to get help if you open an issue on the swiftenv github repository, not here.

1 Like

The command you need to use is

swiftenv versions

(not swift versions).

1 Like

swiftenv versions command did worked but still its showing version not set.

That's because you never set the version.

swiftenv versions lists the available versions. To set the version to 5.3, for example, run:

swiftenv global 5.3

swiftenv --help gives you information on how to use this tool.

1 Like

Ohh yeah😅 It was so obvious.
I never set the version because I didn't know the right command for it.

Thanks btw.:blush:

1 Like