How to install and run Swift on Linux

A step by step guide on how to install Swift on Ubuntu 20.04.

Setup

Download Swift from https://swift.org/download/ -> select the Toolchain archive for Ubuntu 20.04

Extract the archive, then open ~/.bashrc and append this line:

Reload .bashrc with source ~/.bashrc

Install the required dependencies. See https://swift.org/download/#using-downloads -> Linux -> Installation -> Install required dependencies (for Ubuntu 20.04)

Test it, in a terminal:

Create an example app

Make a folder:

Then generate an empty project with:

and run the executable:

Originally published at https://alexadam.dev.