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
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.
provides tooling infrastructure for programming languages in the C programming languages. It acts as a compiler.
provides full-featured Unicode and locale support. This allows for Unicode to be used in our code.
How to install
sudo apt-get install clang libicu-dev
is a command line tool that handles packages. And other tools from the APT library.
2. Download the Swift files
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.
3. Extract the files
tar -xvzf swift-5.1.3-RELEASE*
, acts as a wild card so that
can find the file that starts with
This is going to extract the files and create a folder of the swift binary files named
. X.X.X will be the version number that you installed.
4. Add this to the PATH
We need to add the absolute path, the location where the binaries were extracted, of the binaries to the
variable that way we can actually use the
command in the command line.
Navigate to the location used in steps 2 and 3 and use the command
to see the full path to the binaries. Now to add that path to the
My command looks like this:
5. Verify the Install
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!
If you enjoy my posts, streams, and apps, consider encouraging my efforts.