In this tutorial we will learn how to install Swift programming language on Ubuntu 22.04 LTS operating system. We will use Swift version 5.7.1 for this tutorial. If we are users of apple products, we are used to using applications that run on iOS. If we are curious about what programming language is used to make these applications, then Swift programming language is one of the answers. Swift is an intuitive and friendly programming language to new programmers.
Swift is object-oriented programming language that takes many ideas from popular languages such as Objective-C, Rust, Haskell, Ruby, and Python.
Installing Swift Programming Languange On Ubuntu 22.04
In this short tutorial, we will install Swift version 5.7.1, which is the last stabel version which was launched on Nov 10, 2022. The Swift installatin will be done in the following steps.
- Update Ubutu System
- Install required pacakages
- Download Swift resouce file
- Install Swift Programming language
- Verify Swift version
- Using Swift on Ubuntu
The details of all items will be discussed in the following sub-chapters.
1. Update Ubuntu System
In this step we will update our Ubuntu packages repository, this task is to make sure if we are accessing the latest packages versions. To update our packages software we will use command line :
$ sudo apt update
2. Install Required Packages
Swift requires some dependencies need to be install in our system to run properly. We will install all of them using the following command:
sudo apt install binutils git gnupg2 libc6-dev libcurl4 libedit2 sudo apt install libgcc-9-dev libpython2.7 libsqlite3-0 libstdc++-9-dev libxml2 libz3-dev pkg-config tzdata zlib1g-dev
Output :
ramans@infodiginet:~$ sudo apt install binutils git gnupg2 libc6-dev libcurl4 libedit2 Reading package lists... Done Building dependency tree... Done Reading state information... Done libedit2 is already the newest version (3.1-20210910-1build1). libedit2 set to manually installed. libcurl4 is already the newest version (7.81.0-1ubuntu1.6). libcurl4 set to manually installed. The following additional packages will be installed: binutils-common binutils-x86-64-linux-gnu git-man libbinutils libc-dev-bin libc-devtools libcrypt-dev libctf-nobfd0 libctf0 liberror-perl libnsl-dev libtirpc-dev linux-libc-dev manpages-dev rpcsvc-proto Suggested packages: binutils-doc git-daemon-run | git-daemon-sysvinit git-doc git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn glibc-doc The following NEW packages will be installed: binutils binutils-common binutils-x86-64-linux-gnu git git-man gnupg2 libbinutils libc-dev-bin libc-devtools libc6-dev libcrypt-dev libctf-nobfd0 libctf0 liberror-perl libnsl-dev libtirpc-dev linux-libc-dev manpages-dev rpcsvc-proto 0 upgraded, 19 newly installed, 0 to remove and 10 not upgraded. Need to get 13,8 MB of archives. After this operation, 62,1 MB of additional disk space will be used. Do you want to continue? [Y/n] Y
ramans@infodiginet:~$ sudo apt install libgcc-9-dev libpython2.7 libsqlite3-0 libstdc++-9-dev libxml2 libz3-dev pkg-config tzdata zlib1g-dev Reading package lists... Done Building dependency tree... Done Reading state information... Done libsqlite3-0 is already the newest version (3.37.2-2ubuntu0.1). libsqlite3-0 set to manually installed. libxml2 is already the newest version (2.9.13+dfsg-1ubuntu0.2). libxml2 set to manually installed. tzdata is already the newest version (2022f-0ubuntu0.22.04.1). tzdata set to manually installed. The following additional packages will be installed: gcc-9-base libasan5 libdpkg-perl libfile-fcntllock-perl libitm1 liblsan0 libpython2.7-minimal libpython2.7-stdlib libquadmath0 libtsan0 libubsan1 libz3-4 Suggested packages: debian-keyring gcc | c-compiler bzr libstdc++-9-doc dpkg-dev The following NEW packages will be installed: gcc-9-base libasan5 libdpkg-perl libfile-fcntllock-perl libgcc-9-dev libitm1 liblsan0 libpython2.7 libpython2.7-minimal libpython2.7-stdlib libquadmath0 libstdc++-9-dev libtsan0 libubsan1 libz3-4 libz3-dev pkg-config zlib1g-dev 0 upgraded, 18 newly installed, 0 to remove and 10 not upgraded. Need to get 21,8 MB of archives. After this operation, 96,3 MB of additional disk space will be used. Do you want to continue? [Y/n] Y
3. Download Swift resouce file
In this step, we will download Swift programming language source. We will use wget command line to download Swift from its Swift official web site. We will select Swift source for Ubuntu 22.04 Jammy operating system.
$ wget https://download.swift.org/swift-5.7.1-release/ubuntu2204/swift-5.7.1-RELEASE/swift-5.7.1-RELEASE-ubuntu22.04.tar.gz
Output :
ramans@infodiginet:~$ wget https://download.swift.org/swift-5.7.1-release/ubuntu2204/swift-5.7.1-RELEASE/swift-5.7.1-RELEASE-ubuntu22.04.tar.gz --2022-12-11 22:02:28-- https://download.swift.org/swift-5.7.1-release/ubuntu2204/swift-5.7.1-RELEASE/swift-5.7.1-RELEASE-ubuntu22.04.tar.gz Resolving download.swift.org (download.swift.org)... 17.253.83.203, 17.253.83.201, 2403:300:a06:f000::3, ... Connecting to download.swift.org (download.swift.org)|17.253.83.203|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 537074983 (512M) [application/octet-stream] Saving to: ‘swift-5.7.1-RELEASE-ubuntu22.04.tar.gz’ swift-5.7.1-RELEASE-ubuntu22.04. 100%[=======================================================>] 512,19M 1,52MB/s in 15m 27s 2022-12-11 22:17:56 (566 KB/s) - ‘swift-5.7.1-RELEASE-ubuntu22.04.tar.gz’ saved [537074983/537074983]

4. Install Swift Programming language
After download is completed done, then we will extract the file, move and make it to be executable.
- move Swift to be under /opt/swift directory
- adding the Swift folder to system path
- reload bash
ramans@infodiginet:~$ sudo mv swift-*-RELEASE-ubuntu22.04 /opt/swift/ [sudo] password for ramans: ramans@infodiginet:~$ echo "export PATH=/opt/swift/usr/bin:$PATH" >> ~/.bashrc ramans@infodiginet:~$ source ~/.bashrc
5. Verify Swift version
Once the installation of Swift is completed, we will verify the installation by querying its version using the below-given command linr :
$ swift --version
Output :
ramans@infodiginet:~$ swift --version Swift version 5.7.1 (swift-5.7.1-RELEASE) Target: x86_64-unknown-linux-gnu

6. Using Swift on Ubuntu
In this stage, we will try to use swift programming language. We will log in to shell Swift by typing swift
from the console.

From this point, we can start to make an application crafted by Swift. To learn the basics of Swift programming, we can visit the Swift official documentation.