Skip to content

Instantly share code, notes, and snippets.

@greister
Forked from Azoy/install-swift-ubuntu.md
Created February 6, 2018 17:48
Show Gist options
  • Save greister/3a5a1faed2b873e1733ef980356c5d14 to your computer and use it in GitHub Desktop.
Save greister/3a5a1faed2b873e1733ef980356c5d14 to your computer and use it in GitHub Desktop.
Guide on how to install Swift on Ubuntu

Install Swift on Ubuntu

Requirements

  1. Ubuntu 14.04, 16.04, or 16.10

Step 1 - Dependencies

  1. Open up terminal
  2. Install core deps: sudo apt-get install clang libicu-dev git

Step 1.1 - Ubuntu 14.04 Clang

If you're using Ubuntu 14.04, you need to update to clang 3.6 to prevent errors in the future.

  1. Install updated clang: sudo apt-get install clang-3.6
  2. Update clang: sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.6 100
  3. Update clang++: sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.6 100

Step 2 - Install SwiftEnv

I put this application in here because it greatly helps with handling multiple versions of Swift.

  1. Make the swiftenv folder: mkdir .swiftenv
  2. Clone the repo: git clone https://github.com/kylef/swiftenv ~/.swiftenv
  3. Add swiftenv to bash profile #1: echo 'export SWIFTENV_ROOT="$HOME/.swiftenv"' >> ~/.bashrc
  4. Add swiftenv to bash profile #2: echo 'export PATH="$SWIFTENV_ROOT/bin:$PATH"' >> ~/.bashrc
  5. Add swiftenv to bash profile #3: echo 'eval "$(swiftenv init -)"' >> ~/.bashrc
  6. Restart the terminal, or run source ~/.bashrc

Step 3 - Install Swift

Follow the table to know what value to insert in the link below

Ubuntu 14.04 Ubuntu 16.04 Ubuntu 16.10
#1 ubuntu1404 ubuntu1604 ubuntu1610
#2 ubuntu14.04 ubuntu16.04 ubuntu16.10
  1. Install Swift 4.0.3 to swiftenv: swiftenv install https://swift.org/builds/swift-4.0.3-release/#1/swift-4.0.3-RELEASE/swift-4.0.3-RELEASE-#2.tar.gz

That's it! Swift 4.0.3 is installed on your Ubuntu device and you can check with swift --version to make sure you're running Swift 4.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment