How to Install Swift Programming Language on Fedora 35

Swift, often referred to as “Objective-C, without the C,” is an open-source programming language developed and maintained by AppleSwift 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.

Advertisement

Prerequisites

  • 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:

sudo whoami

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.

su

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

Example output:

How to Install Swift Programming Language on Fedora 35

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

Example output:

Swift version 5.5 (swift-5.5-RELEASE)
Target: x86_64-unknown-linux-gnu
Advertisement

Connect to Swift REPL

To connect to the Swift REPLL (Read Eval Print Loop) can be achieved using the following command:

swift

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:

How to Install Swift Programming Language on Fedora 35

To exit the Swift terminal, use the following command:

:q
Advertisement

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

Example output:

How to Install Swift Programming Language on Fedora 35

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.

Subscribe
Notify of
2 Comments
Inline Feedbacks
View all comments
louis le pegue
Guest
Monday, December 13, 2021 12:53 am

Hi

Does your implantation include the Swift debugger ?
It’s a must have for me.

Thank you

adplus-dvertising
2
0
Would love your thoughts, please comment.x
()
x