In this guide, I’m going to write the commands and steps needed to install Swift on Ubuntu 18.04 LTS. My server is going to be hosted by Linode, but it should work on any computer running Ubuntu 18.04 LTS. Since I’m doing this on Linode, all of the instructions will be how to install Swift using the command line.
Let’s get started by accessing your Ubuntu 18.04 LTS instance. For me, this means using SSH to access my server.
Note : When installing, I’m going to put
sudo before my commands because we need root access to install into some of the directories. If you have root access, you should not need
Two packages need to be installed since they are dependencies. I want to explain what they are before actually installing them.
clang provides tooling infrastructure for programming languages in the C programming languages. It acts as a compiler.
libicu-dev provides full-featured Unicode and locale support. This allows for Unicode to be used in our code.
sudo apt-get install clang libicu-dev
apt-get is a command line tool that handles packages. And other tools from the APT library.
Apple hosts the Swift files to download on Swift.org/downloads. You can go there to get the URL to download the latest release of Swift or the version that you need.
Note: As of writing this guide, the latest release is 5.1.3 which is what I will use in the commands
Navigate to the location where you want to download the binary of the Swift version you want to install. I keep mine in the src folder, so the command below will take me there.
Now, let’s download the binary files.
Let this command finish, and then continue to step 3.
tar -xvzf swift-5.1.3-RELEASE*
swift-5.1.3-RELEASE, acts as a wild card so that
tar -xvzf can find the file that starts with
This is going to extract the files and create a folder of the swift binary files named
swift-X.X.X-RELEASE-ubuntu18.04. X.X.X will be the version number that you installed.
We need to add the absolute path, the location where the binaries were extracted, of the binaries to the
PATH variable that way we can actually use the
swift command in the command line.
Navigate to the location used in steps 2 and 3 and use the command
pwd to see the full path to the binaries. Now to add that path to the
My command looks like this:
Swift is now installed. Let’s verify that it works use the following.
The terminal should show what version you are using. Mine shows
Swift version 5.1.3 and some more things about the version, and that is it!
or support my work monthly on Patreon.