www.robkerr.com
www.robkerr.com

mobile development, cloud computing and building great software

Rob Kerr
Author

Addicted to coding since writing my first programs for the Commodore computers in the 1980s. Currently working as an independent contractor focused on native iOS development.

Share


Tags


Twitter


www.robkerr.com

Install Swift 3.0 on Ubuntu Linux 16.04 LTS

Rob KerrRob Kerr

Since Apple released Swift to open source last year, there's been a grass roots movement to begin building a server-side ecosystem around Swift.

Before doing any server-side development with Swift, though, it needs to be installed first!

Below are the steps I took to install Swift 3.0 on my AWS EC2-based Ubuntu 16 LTS development server:

Install Dependencies

Swift has a couple base dependencies needed for it to run on Linux.

sudo apt-get install clang libicu-dev

Download pre-compiled binaries

As of this writing, apt-get on Ubuntu 16 didn't catalog Swift 3.0, so I downloaded the precompiled binary. Also, the Ubuntu 16.04 binary available was from the 3.0.1 Preview distribution. So don't use the links I have here directly -- go to the Swift Download Page and check for the latest Release distribution (if available) for your Ubuntu version.

$ wget https://swift.org/builds/swift-3.0.1-preview-1/ubuntu1604/swift-3.0.1-PREVIEW-1/swift-3.0.1-PREVIEW-1-ubuntu16.04.tar.gz

Extract the tar file

$ tar -xvf swift-3.0.1-PREVIEW-1-ubuntu16.04.tar.gz

Move swift into a production folder

$ sudo mkdir /opt/swift/swift-3.0
$ mv swift-3.0.1-PREVIEW-1-ubuntu16.04/usr /opt/swift/swift-3.0

For a discussion of why swift is placed under /opt, refer to this discussion thread.

Add swift to the ~/.profile path

Add the following to the tail of ~/.profile

PATH=$PATH:/opt/swift/swift-3.0/usr/bin

Either logout/login, or refresh the profile:

source ~/.profile

Check that swift is available on the path and will run

$ cd ~
$ swift --version
Swift version 3.0 (swift-3.0.1-PREVIEW-1)
Target: x86_64-unknown-linux-gnu

With that, the basic install of Swift is ready to go for utility scripts or server-side development.

Rob Kerr
Author

Rob Kerr

Addicted to coding since writing my first programs for the Commodore computers in the 1980s. Currently working as an independent contractor focused on native iOS development.

Comments