NOTE: If you're on macOS, consider installing with Homebrew.
-
Check out swiftenv, we recommend
~/.swiftenv
(but it can be installed elsewhere as long as you setSWIFTENV_ROOT
).$ git clone https://github.com/kylef/swiftenv.git ~/.swiftenv
-
Configure environment.
For Bash:
$ echo 'export SWIFTENV_ROOT="$HOME/.swiftenv"' >> ~/.bash_profile $ echo 'export PATH="$SWIFTENV_ROOT/bin:$PATH"' >> ~/.bash_profile $ echo 'eval "$(swiftenv init -)"' >> ~/.bash_profile
NOTE: On some platforms, you may need to modify
~/.bashrc
instead of~/.bash_profile
.For ZSH:
$ echo 'export SWIFTENV_ROOT="$HOME/.swiftenv"' >> ~/.zshenv $ echo 'export PATH="$SWIFTENV_ROOT/bin:$PATH"' >> ~/.zshenv $ echo 'eval "$(swiftenv init -)"' >> ~/.zshenv
For Fish:
$ echo 'set -gx SWIFTENV_ROOT "$HOME/.swiftenv"' >> ~/.config/fish/config.fish $ echo 'set -gx PATH "$SWIFTENV_ROOT/bin" $PATH' >> ~/.config/fish/config.fish $ echo 'if which swiftenv > /dev/null; status --is-interactive; and source (swiftenv init -|psub); end' >> ~/.config/fish/config.fish
For other shells, please open an issue and we will visit adding support.
-
Restart your shell so the changes take effect.
You can install swiftenv using the Homebrew package manager on macOS.
-
Install swiftenv
$ brew install kylef/formulae/swiftenv
-
Then configure the shims and completions by adding the following to your profile.
For Bash:
$ echo 'if which swiftenv > /dev/null; then eval "$(swiftenv init -)"; fi' >> ~/.bash_profile
NOTE: On some platforms, you may need to modify
~/.bashrc
instead of~/.bash_profile
.For ZSH:
$ echo 'if which swiftenv > /dev/null; then eval "$(swiftenv init -)"; fi' >> ~/.zshrc
For Fish:
$ echo 'if which swiftenv > /dev/null; status --is-interactive; and source (swiftenv init -|psub); end' >> ~/.config/fish/config.fish
-
Remove swiftenv from any
.bash_profile
,.bashrc
,.zshrc
,fish.config
that you've added during installation. -
Remove
SWIFTENV_ROOT
aka,~/.swiftenv
.$ rm -fr ~/.swiftenv
-
Uninstall any swiftenv packages (brew uninstall, pacman, etc).