Swift, often referred to as “Objective-C, without the C,” is an open-source programming language developed and maintained by Apple. Swift is a general-purpose programming language built using modern safety, performance, and software design patterns. The Swift project aims to create the best available language for systems programming to mobile and desktop apps, scaling up to cloud services.
In the following tutorial, you will learn how to install Swift Programming Language on your Fedora 35 system.
Table of Contents
- Recommended OS: Fedora Linux 35
- User account: A user account with sudo or root access.
Update Operating System
Update your Fedora operating system to make sure all existing packages are up to date:
sudo dnf upgrade --refresh -y
The tutorial will be using the sudo command and assuming you have sudo status.
To verify sudo status on your account:
Example output showing sudo status:
[joshua@fedora ~]$ sudo whoami root
To set up an existing or new sudo account, visit our tutorial on Adding a User to Sudoers on Fedora.
To use the root account, use the following command with the root password to log in.
Install Swift Programming Language
By default, Swift is available in Fedora’s repositories. Given Fedora is a six-month release nearly always has the most up-to-date version of Swift available compared to other distributions where it’s outdated or does not exist at all, making the installation a fast process.
First, install Swift with the dnf install command as below.
sudo install swift-lang
Type Y, then press the ENTER KEY to proceed and complete the installation.
To verify the Swift installation, check the build and version with the following command.
Swift version 5.5 (swift-5.5-RELEASE) Target: x86_64-unknown-linux-gnu
Connect to Swift REPL
To connect to the Swift REPLL (Read Eval Print Loop) can be achieved using the following command:
You can write valid Swift statements in this terminal and see them evaluated, and you can even use standard C Libraries by importing the GNU C Libary.
Below are some basic examples of Swift in action:
let name = "Joshua James"
import Glibc // imports GNU C Library var ln = random () % 100
print(“Thank You LinuxCapable.com for learning how to Install Swift on Fedora 35”)
Example in terminal:
To exit the Swift terminal, use the following command:
How to Update Swift
For updates to Swift, use the standard refresh command.
sudo dnf upgrade --refresh
This will also update any other outdated packages on your system, and this is advisable to keep a secure safe working system.
How to Remove (Uninstall) Swift
Removing the language is relatively easy for users who no longer require Swift on their Fedora system since it was installed using the dnf package manager.
In your terminal, execute the following command:
sudo dnf autoremove swift-lang
Type Y, then press the ENTER KEY to proceed and complete the removal.
Comments and Conclusion
In the tutorial, you have learned how to install Swift programming language by downloading and importing the PGP key, extracting the bash and path required, and basic commands to get a feel for the Swift terminal.