How to Install Swift on Ubuntu 24.04
You can install Swift on Ubuntu 24.04 by downloading the official Swift toolchain directly or by using the system’s package manager.
Swift is a powerful, open-source programming language developed by Apple, designed for building everything from mobile apps to server applications. Its availability on Linux systems like Ubuntu 24.04 unlocks significant cross-platform development potential.
This guide helps you get Swift up and running on your Ubuntu 24.04 LTS system, focusing on the latest stable releases.
You can leverage Swift for web development, system programming, and even mobile development for platforms beyond Apple’s ecosystem.
Install Swift on Ubuntu 24.04 by first installing prerequisite packages using apt. Then, download the Swift toolchain binary from the official Swift website, verify its signature, extract it to /opt, and add Swift’s bin directory to your PATH.
Prepare Ubuntu
First, you’ll need to know the release and codename of your Ubuntu version.
Then, download the appropriate version of Swift for your system.
Run the command to verify the Ubuntu release and codename of your system.
lsb_release -a
If you run Ubuntu 24.04, the command should return release version 24.04 and codename noble.
After that, install these packages on Ubuntu.
sudo apt-get install binutils git gnupg2 libc6-dev libcurl4-openssl-dev libedit2 libgcc-13-dev libncurses-dev libpython3-dev libsqlite3-0 libstdc++-13-dev libxml2-dev libz3-dev pkg-config tzdata unzip zlib1g-dev
Download Swift
Once your Ubuntu system is ready, use the download page to download your system’s latest version of Swift.
You can also use the command below to download Swift 6.0.3 binary. Replace the version number with the latest.
wget https://download.swift.org/swift-6.0.3-release/ubuntu2404/swift-6.0.3-RELEASE/swift-6.0.3-RELEASE-ubuntu24.04.tar.gz
Before you install, it’s important to download the Swift GPG key (a security key to verify package authenticity) for its packages. Run this command:
wget -q -O - https://swift.org/keys/all-keys.asc | gpg --import -
gpg --keyserver hkp://keyserver.ubuntu.com --refresh-keys Swift
Next, download the Swift signature file for the installer and verify it by running the command below.
wget https://download.swift.org/swift-6.0.3-release/ubuntu2404/swift-6.0.3-RELEASE/swift-6.0.3-RELEASE-ubuntu24.04.tar.gz.sig
gpg --verify swift-6.0.3-RELEASE-ubuntu24.04.tar.gz.sig
Finally, extract the downloaded installer and move the file into the /opt directory.
tar xzf swift-6.0.3-RELEASE-ubuntu24.04.tar.gz
sudo mv swift-6.0.3-RELEASE-ubuntu24.04/* /opt/swift
Configure Swift
After extracting the file, add the Swift command to your command PATH (a list of directories where your system looks for executable commands) by running the command below.
echo "export PATH=$PATH:/opt/swift/usr/bin" >> $HOME/.profile
source $HOME/.profile
To verify that Swift is installed and ready, run the command below.
swift --version
The command should return the current version that was installed.
You can start Swift by running the command below.
swift
That should do it.
Conclusion:
So, installing Swift on Ubuntu 24.04 gives you a powerful tool for cross-platform development. Here are the key takeaways:
- Versatility: Swift allows for developing applications across multiple operating systems, enhancing your ability to reach a broader audience.
- GPG Key Security: Downloading and verifying the Swift GPG key ensures the integrity and authenticity of your installation.
- Easy Installation: The installation process is straightforward, making it accessible for developers of all experience levels.
- Path Configuration: Properly setting the command PATH is essential for utilizing Swift commands seamlessly in your terminal.
- Ready for Development: Swift is instantly available to develop robust applications in a Linux environment after installation.
By following these steps, you can successfully leverage the capabilities of Swift on Ubuntu, expanding your development toolkit.
Where to install Swift?
Install Swift by going to the Swift Install Page of swift.org and following the instructions there. You can install another toolchain, such as the latest nightly snapshot of the main branch. Use it so that when you run a toolchain command, it uses that one. For more detailed usage guides, there is documentation.
Can Swift be installed on Linux?
Swift.org provides download packages for Ubuntu 16.04, Ubuntu 18.04, Ubuntu 20.04, CentOS 7, CentOS 8, and Amazon Linux 2. Other distributions also have official support, such as Fedora, Red Hat Enterprise Linux 8, Raspbian OSi, etc.
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!