DEV Community

Maegan Wilson
Maegan Wilson

Posted on • Originally published at Medium on

Installing Swift on Ubuntu 18.04 LTS 💻

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 sudo.

1. Install clang and libicu-dev

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.

How to install

sudo apt-get install clang libicu-dev

Enter fullscreen mode Exit fullscreen mode

apt-get 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 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.

cd src

Enter fullscreen mode Exit fullscreen mode

Now, let’s download the binary files.


Enter fullscreen mode Exit fullscreen mode

Let this command finish, and then continue to step 3.

3. Extract the files

tar -xvzf swift-5.1.3-RELEASE*

Enter fullscreen mode Exit fullscreen mode

The *, after swift-5.1.3-RELEASE, acts as a wild card so that tar -xvzf can find the file that starts with swift-5.1.3-RELEASE.

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.

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 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 PATH.

export PATH=path_shown_using_pwd

Enter fullscreen mode Exit fullscreen mode

My command looks like this:

export PATH=/home/mw/src/swift-5.1.3-RELEASE-ubuntu18.04

Enter fullscreen mode Exit fullscreen mode

5. Verify the Install

Swift is now installed. Let’s verify that it works use the following.

swift -version

Enter fullscreen mode Exit fullscreen mode

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.

Buy Me A Coffee

Top comments (0)