In this tutorial, we will show you how to install Swift Programming Language on CentOS 8. For those of you who didn’t know, Swift is a modern open-source high-performing programming language. Mainly it is used for iOS app development but, you can use it for systems programming, cloud services, and designing other applications. It was developed by Apple and released in 2014. Swift was designed as a replacement for the older Objective-C language.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the Swift Programming Language on CentOS 8.
Prerequisites
- A server running one of the following operating systems: CentOS 8.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Swift Programming Language on CentOS 8
Step 1. First, let’s start by ensuring your system is up-to-date.
sudo dnf clean all sudo dnf update sudo yum install epel-release sudo dnf install clang libcu-devel
Step 2. Installing Swift Programming Language on CentOS 8.
- Install Swift from the official website.
Now we download the Swift packages installer from the official website:
https://swift.org/builds/swift-5.3.3-release/centos8/swift-5.3.3-RELEASE/swift-5.3.3-RELEASE-centos8.tar.gz
Then, extract the downloaded file:
tar xzf swift-5.3.3-RELEASE-centos8.tar.gz sudo mv swift-5.3.3-RELEASE-centos8 /opt/swift/usr/bin
Next, configure the swift binary to the system’s PATH environment variable:
echo 'export PATH=/opt/swift/usr/bin:$PATH' >> ~/.bashrc source ~/.bashrc
To make sure that swift has been installed properly, open the terminal and run the following command to check the swift version:
swift --version
- Install Swift via Snap.
Now run the following command to install Snap packages:
sudo yum install snapd sudo systemctl enable --now snapd.socket sudo ln -s /var/lib/snapd/snap /snap
To install swift-lang, simply use the following command:
sudo snap install swift-lang --edge
Congratulations! You have successfully installed Swift. Thanks for using this tutorial for installing the Swift Programming Language on CentOS 8 systems. For additional help or useful information, we recommend you check the official Swift website.