UbuntuUbuntu Based

How To Install Swift Programming Language on Ubuntu 22.04 LTS

Install Swift Programming Language on Ubuntu 22.04

In this tutorial, we will show you how to install Swift Programming Language on Ubuntu 22.04 LTS. Swift, the versatile and efficient programming language developed by Apple, has gained widespread popularity in the software development world. While it’s commonly associated with iOS and macOS app development, Swift has made its mark as a robust choice for server-side applications and beyond.

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 Ubuntu 22.04. You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.


  • A server running one of the following operating systems: Ubuntu 22.04, 20.04, and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Swift.
  • A non-root sudo user or access to the root user. We recommend acting as a non-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 Ubuntu 22.04 LTS Jammy Jellyfish

Step 1. Begin by updating the package lists to make sure you have the most recent information about available software. Open your Terminal and run:

sudo apt update
sudo apt upgrade

Step 2. Installing Required Dependencies,

Swift relies on specific dependencies, such as Clang and libicu. You can install them using the following command:

sudo apt install clang libicu-dev

To ensure that these dependencies have been successfully installed, you can verify their versions. Run the following command to check the Clang version:

clang --version

Step 3. Installing Swift Programming Language on Ubuntu 22.04.

Now that your system is ready, you can proceed with downloading Swift. The process involves choosing a Swift version and acquiring the necessary tarball:

wget https://download.swift.org/swift-5.9.1-release/ubuntu2204/swift-5.9.1-RELEASE/swift-5.9.1-RELEASE-ubuntu22.04.tar.gz

Create a directory where Swift will be installed. You can choose a location based on your preferences, but /opt/swift is a common choice:

sudo mkdir /opt/swift

Extract the downloaded Swift tarball into the directory you created. This ensures that the Swift executable and libraries are placed in the right location:

sudo tar -xzf swift-5.9.1-RELEASE-ubuntu22.04.tar.gz -C /opt/swift --strip-components=1

To conveniently run Swift from any directory, you need to add Swift to your system’s PATH. Open your .bashrc or .zshrc file using a text editor and add the following line:

export PATH=/opt/swift/usr/bin:"$PATH"

After making this change, apply it by running:

source ~/.bashrc

Alternatively, for the Zsh shell:

source ~/.zshrc

Confirm that Swift is installed correctly by running the following command:

swift --version

This command will display the Swift version and other relevant information, indicating that Swift is successfully set up on your system.

Step 4. Troubleshooting.

Even with a well-defined installation process, you might encounter issues. Here are some common problems and their solutions:

Common Installation Issues

  • Dependency Issues: Ensure that the required dependencies, such as clang and libicu-dev, are installed correctly.
  • Incorrect Version Downloads: Double-check that you’ve downloaded the Swift version compatible with your Ubuntu 22.04 system.
  • PATH Configuration Errors: Verify that you’ve correctly added Swift to your system’s PATH.

Congratulations! You have successfully installed Swift. Thanks for using this tutorial for installing the Swift Programming Language on the Ubuntu system. For additional help or useful information, we recommend you check the official Swift website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button