Install Swift on Ubuntu 20.04 - Best Method ?

Swift is a high-performance, fully accessible real language with an emphasis on security. Apple created it, and it was launched in 2014. Swift was created to take the role of the outdated Objective-C programming language. Initially private, Apple open-sourced the semantic in 2015 and opened it public for GNU/Linux platforms. Although Swift is best recognized for its application in developing apps, it is increasingly being utilized for server-side software development on Debian. Furthermore, because it is a relatively new free software general-purpose semantic of programming, its application in many other fields may develop over time. 

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Software Installation tasks on Debian Linux System.

In this context, we shall look into the best method to install Swift on Ubuntu.

How to Install Swift on Ubuntu ?

To perform this Installation task, simply follow the steps outlined below.

1. Update Ubuntu 20.04 Linux system

Login from Ubuntu 20.04 system and open the shell terminal with a Ctrl+Alt+T shortcut key. After opening it, you need to update the apt package of your system and upgrade it. Hence, execute the below-stated instruction and hit the Enter button. Upon request, enter the sudo password and press the button of "Enter":

$ sudo apt update && sudo apt upgrade

2. Install Dependencies

To install and download the swift package on your system, we need to first install some of the dependencies needed for the installation and configuration of swift. These dependencies include git, some of the binary utilities, python libraries, sqlite library, compiler libraries, curl library, GNU library, and many more standard c++ libraries. Hence, try out the below query consisting of all the required dependencies or packages that should be installed first. It may require your sudo password to continue the process. Enter the password and hit Enter:

$ sudo apt install binutils git gnupg2 libc6-dev libcurl4 libedit2 libgcc-9-dev libpython2.7 libsqlite3-0 libstdc++-9-dev libxml2 libz3-dev pkg-config tzdata zlib1g-dev

Between the installation of dependencies, it will pause the process and ask you to affirm your action. If you want to install these dependencies then hit the Y key and press Enter. Otherwise press N and hit Enter to quit this process.

3. Download Swift Package

Now. It’s time to download the swift package on our system. For this purpose, we need to download it from the official download page of the swift website. Hence, try out the below link containing the query in your shell using the wget package to download it. It may take up to 1 hour or evern ore or less depending upon the speed of your internet and device:

$ wget

4. Extract and Install Swift Package

Now the package has been downloaded effectively, we have to extract its content. So, to extract it use the below query in your shell:

$ tar xzf swift-5.3.3-RELEASE-ubuntu20.04.tar.gz

Now it's time to change the location of extracted contents. Hence we have to move to the folder "share" using the below-stated query:

$ sudo mv swift-5.3.3-RELEASE-ubuntu20.04 /usr/share/swift

After this, we have to fix the Swift's path in our system PATH's environment using the below command in the terminal shell:

$ echo “export PATH=/usr/share/swift/usr/bin:$PATH” >> ~/.bashrc

Now, execute the bashrc file to implement your changes using the source command:

$ source ~/.bashrc

After the installation has been done, check the installed version of swift on your system via the below version query:

$ swift –version

To start Swift, execute the below simple query to do so:

$ swift

It will not only show you the version of swift installed but also you can type anything to be executed. To see if the installed Swift has been working properly, write out any print statement in the code area to see the output.

[Need help in Installing Software on Ubuntu Linux System? We can help you. ]

This article covers how to install Swift on Ubuntu 20.04 LTS. Swift is a programming language developed from C and objective-C which uses variables to store and refer to values. Constants are used throughout.

Related Posts