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.
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.
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-
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
5. Check the version
Now, we can check the version of the Swift, use the given command:
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.
Now, we can start programming. To learn the basics of Swift programming, you can visit the official documentation.
• 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