Installing Swift on Ubuntu 18.04 LTS 💻
Tags: swift, linux
Published: 2020-01-31 23:40:43

---
title: Installing Swift on Ubuntu 18.04 LTS 💻
published: true
date: 2020-01-31 20:53:18 UTC
tags: Swift, Linux
canonical_url: https://medium.com/@maeganwilson_/installing-swift-on-ubuntu-18-04-lts-d60b730647d5
---

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](www.linode.com), 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`

`clang` provides tooling infrastructure for programming languages in the C programming languages. It acts as a compiler.

## `libicu-dev`

`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

```

`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 [Swift.org/downloads](https://swift.org/download/ "Swift.org"). 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

```

Now, let’s download the binary files.

```
wget https://swift.org/builds/swift-5.1.3-release/ubuntu1804/swift-5.1.3-RELEASE/swift-5.1.3-RELEASE-ubuntu18.04.tar.gz

```

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

# 3. Extract the files

```
tar -xvzf swift-5.1.3-RELEASE*

```

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

```

My command looks like this:

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

```

# 5. Verify the Install

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

```
swift -version

```

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.

[![](https://github.com/maeganjwilson/appsbymwblog/blob/master/static/images/patron.png?raw=true)](https://www.patreon.com/appsbymw)

<a href="https://www.buymeacoffee.com/appsbymw" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/arial-blue.png" alt="Buy Me A Coffee" style="height: 51px !important;width: 217px !important;" ></a>