In this guide, we are looking at how to install swift programming language on Ubuntu 20.04. Swift is a programming language developed from C and objective-C which uses variables to store and refer to values. Constants are used throughout. Swift programming language developed for iOS, macOS, watchOS, and tvOS development.

Swift is the best available language for all programmers systems ranging from mobile and desktop apps, even up to cloud services. it is designed to make writing and maintaining fast and safe programs. Follow the steps below to install Swift on Ubuntu 20.04.

Step 1: Update System Packages

Ensure that you have your system packages up to date before beginning your installations. Run the commands below:

sudo apt-get update
sudo apt-get upgrade

Step 2: Install Required Dependencies

You need to install some dependencies that are required to run Swift on Ubuntu 20.04. Run the command below:

sudo apt install clang libicu-dev libpython2.7-dev libtinfo5 libncurses5 libpython2.7 libz3-dev

Step 3. Installing swift on Ubuntu 20.04

Download the latest version of swift from their official download page. Alternatively, you can use wget to download as below:

wget -c https://swift.org/builds/swift-5.3.3-release/ubuntu2004/swift-5.3.3-RELEASE/swift-5.3.3-RELEASE-ubuntu20.04.tar.gz

Now extract the downloaded file and configure the swift binary to system’s PATH environment variable.

tar xzf swift-5.3.3-RELEASE-ubuntu20.04.tar.gz
sudo mv swift-5.3.3-RELEASE-ubuntu20.04 /usr/share/swift
echo "export PATH=/usr/share/swift/usr/bin:$PATH" >> ~/.bashrc
source  ~/.bashrc

Step 4: Verify Swift Installation

We can check for the installed version of swift to confirm that it is properly installed

$ swift --version
Swift version 5.3.3 (swift-5.3.3-RELEASE)
Target: x86_64-unknown-linux-gnu

Step 5: Run a simple Swift Program

To enter Swift command line, simply type ‘swift‘ on your terminal and press ‘Enter

$ swift
Welcome to Swift version 5.3.3 (swift-5.3.3-RELEASE).
Type :help for assistance.
  1>  

To run a simple ‘hello world’ program, simply use ‘print

1> print("Hello World!")
Hello World!
  2>  

That’s it. You have successfully installed Swift programming language on Ubuntu 20.04 and run your first simple program. Swift is quite interesting due to the various uses it supports. It is easy to use. Enjoy! More interesting guides on programming below: