Install Swift programming language on Ubuntu 20.04 LTS Jammy

Learn the steps and commands to install Appleā€™s programming language called Swift on Ubuntu 20.04 LTS Focal fossa Linux with the help of Terminal.

What is Swift Langauge?

Swift is a programming language developed by Apple that can be used alongside Objective-C for programming apps and applications. It is a beginner-friendly language that a developer can use to develop apps for iOS. It was introduced to the world in 2014 as a new programming language for programming in the Apple ecosystem.

The language is especially relevant in the development of iOS apps, but can also be used in the macOS environment. However, Swift is not limited to Apple systems, Linux users can also use it to develop applications.

Swift has strong, static typing and relies on a syntax reduced to the essentials for optimal readability. This modern programming language is object-oriented that takes many ideas from popular languages such as Objective-C, Rust, Haskell, Ruby, and Python.

Steps to install Swift on Ubuntu 22.04 LTS Linux

1. Update System

First, run the system update command that will fetch and install the latest security updates and make sure the systemā€™s package index is up to date.

sudo apt update

 

2. Install packages needed for Swift

There are few packages or dependencies we required to install and configure Swift on our Ubuntu 20.04 LTS system. Hence, first, install the same.

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

 

3. Download Swift on Ubuntu 20.04

Swift is not available to install using the default system repository of Ubuntu 20.04, therefore we have to download the latest release of this programming language available on its official website. You can visit the website to download it directly using your browser.

Download Swift on Ubuntu 20.04

Alternatively, we can use the wget command. While doing this article the latest release was 5.6.1. Right Click on theĀ  x86_64 and copy the link. After that use it with wget.

wget past-link

wget https://download.swift.org/swift-5.6.1-release/ubuntu2004/swift-5.6.1-RELEASE/swift-5.6.1-RELEASE-ubuntu20.04.tar.gz

 

4. Install Swift Programming language

After having the file on your system, the next step is to extract the file and keep it somewhere safe, so that we can use it to start programming.

Note: If you have used the browser to download the Swift file, then first we have to switch to the ā€œDownloadsā€ directory. For that use- cd Downloads

tar -xvf swift-*-RELEASE-ubuntu20.04.tar.gz

Move it to /opt

sudo mv swift-*-RELEASE-ubuntu20.04 /opt/swift

Add the Swift folder to your system path, so that we can use its command line from anywhere

echo "export PATH=/opt/swift/usr/bin:$PATH" >> ~/.bashrc

reload bash:

source ~/.bashrc

 

5. Check the version

Now, we can check the version of the Swift, use the given command:

swift --version

 

6.Ā  REPL or Read Eval

To get the command line shell of Swift known as REPL or Read Eval, just type the given command in your terminal.

swift

Now, we can start programming. To learn the basics of Swift programming, you can visit the official documentation.

Swift Shel REPL

 

Other Articles:

ā€¢ How to install Oracle Java 8 64-bit Ubuntu 22.04 | 20.04 LTS
ā€¢ Enable or disable the firewall on Ubuntu 22.04 LTS Jammyā€¦
ā€¢ How to Install Python 2 on Ubuntu 22.04ā€¦
ā€¢ How to install Microsoft SQL Server on Ubuntu 20.04
ā€¢ Install FreeTube ā€“ YouTube player app on Ubuntu 20.04

 

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.