Git Product home page Git Product logo

swiftenv's Introduction

Swift Version Manager

Build Status

swiftenv allows you to easily install, and switch between multiple versions of Swift.

This project was heavily inspired by pyenv.

swiftenv screenshot

swiftenv allows you to:

  • Change the global Swift version, per user.
  • Set a per-project Swift version.
  • Allows you to override the Swift version with an environmental variable.

## Installation

NOTE: If you're on OS X, consider installing with Homebrew.

Via a Git clone

  1. Check out swiftenv, we recommend ~/.swiftenv (but it can be installed elsewhere as long as you set SWIFTENV_ROOT).

    $ git clone https://github.com/kylef/swiftenv.git ~/.swiftenv
  2. 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 'setenv SWIFTENV_ROOT "$HOME/.swiftenv"' >> ~/.config/fish/config.fish
    $ echo 'setenv PATH "$SWIFTENV_ROOT/bin" $PATH' >> ~/.config/fish/config.fish
    $ echo 'status --is-interactive; and . (swiftenv init -|psub)' >> ~/.config/fish/config.fish

    For other shells, please open an issue and we will visit adding support.

  3. Restart your shell so the changes take effect.

Via Homebrew

You can install swiftenv using the Homebrew package manager on OS X.

  1. Install swiftenv

    $ brew install kylef/formulae/swiftenv
  2. 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 'status --is-interactive; and . (swiftenv init -|psub)' >> ~/.config/fish/config.fish

Usage

Commands

version

Displays the current active Swift version and why it was chosen.

$ swiftenv version
2.2 (set by /home/kyle/.swiftenv/version)
versions

Lists all installed Swift versions, showing an asterisk next to the currently active version.

$ swiftenv versions
  2.2
* 2.2-SNAPSHOT-2015-12-10-a (set by /home/kyle/.swiftenv/version)
global

Sets the global version of Swift to be used by writing to the ~/.swiftenv/version file. This version can be overridden by application-specific .swift-version file, or by setting the SWIFT_VERSION environment variable.

$ swiftenv global 2.2
$ swiftenv global
2.2
local

Sets the local application-specific Swift version by writing the version to a .swift-version file in the current directory. This version overrides the global version and can also be overridden by th SWIFT_VERSION environment variable.

$ swiftenv local 2.2
$ swiftenv local
2.2
install

Installs a version of Swift. This supports any binary release provides by Apple. For example, a 2.2 snapshots such as 2.2-SNAPSHOT-2016-01-11-a.

You may also specify 2.2-dev to build Swift from source, this will require all of the dependencies mention on Swift system requirements. It is important to note that the Swift Package Manager will not be installed with 2.2-dev as Swift Package Manager is still in early development and it won't be included in 2.2, however it is available in the development binary snapshots.

$ swiftenv install 2.2-SNAPSHOT-2016-01-11-a
Downloading 2.2-SNAPSHOT-2016-01-11-a from https://swift.org/builds/ubuntu1510/swift-2.2-SNAPSHOT-2016-01-11-a/swift-2.2-SNAPSHOT-2016-01-11-a-ubuntu15.10.tar.gz

You may also use URLs to a Swift Binary package URL from Swift Snapshots as a parameter

$ swiftenv install https://swift.org/builds/development/xcode/swift-DEVELOPMENT-SNAPSHOT-2016-03-01-a/swift-DEVELOPMENT-SNAPSHOT-2016-03-01-a-osx.pkg
Downloading https://swift.org/builds/development/xcode/swift-DEVELOPMENT-SNAPSHOT-2016-03-01-a/swift-DEVELOPMENT-SNAPSHOT-2016-03-01-a-osx.pkg
Password:

You may also manually install Swift and make it accessible to swiftenv. Custom Swift installations can either be placed in a directory using the correct version number at ~/.swiftenv/versions/VERSION, or can be symbolic linked into the version directory.

It is expected that all dependencies are already installed for running Swift, please consult the Swift website for more information.

NOTE: After manually installing a version of Swift, it's recommended that you run swiftenv rehash to update the shims.

uninstall

Uninstalls a specific Swift version.

$ swiftenv uninstall 2.2
rehash

Installs shims for the Swift binaries. This command should be ran after you manually install new versions of Swift.

$ swiftenv rehash
which

Displays the full path to the executable that would be invoked for the selected version for the given command.

$ swiftenv which swift
/home/kyle/.swiftenv/versions/2.2/usr/bin/swift

$ swiftenv which lldb
/home/kyle/.swiftenv/versions/2.2/usr/bin/lldb

swiftenv's People

Contributors

kylef avatar lxrd-aj avatar deepumukundan avatar kattrali avatar julien-c avatar kimar avatar nachosoto avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.