How to Install Swift on Ubuntu 24.04
Installing Swift on Ubuntu 24.04 means getting Apple’s programming language onto your Linux computer.
Swift is a versatile, free programming language made by Apple, great for building apps for phones and servers.
Ubuntu 24.04, the latest long-term support version of Ubuntu, can run Swift, opening up possibilities for developing on Linux.
You can install Swift by downloading the official tools directly or by using Ubuntu’s built-in software installer.
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
Your Ubuntu 24.04 system, also called ‘noble’, must be ready for Swift installation. You can check your Ubuntu version by running the lsb_release -a command. This check ensures you download the correct Swift version for your specific Ubuntu setup, which helps prevent installation errors.
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
After preparing your Ubuntu system, you can now download Swift for Ubuntu 24.04. Use the ‘wget’ command to get the Swift 6.0.3 binary. You can find the latest release version on the official Swift download site and replace the version number in the command if a newer one is available.
The command below downloads Swift 6.0.3 binary; remember to 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 installing, download the Swift GPG key, which acts as a security key to verify the authenticity of its packages. Run this command:
Download the Swift signature file for the installer, and then use the command below to verify it, ensuring the downloaded file is genuine.
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
Once Swift is downloaded, you need to add it to your system’s PATH so you can easily run Swift commands. Add Swift’s bin folder to your PATH using the ‘echo’ command. Then, run ‘source $HOME/.profile’ to make these changes active and get Swift ready for use.
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:
Installing Swift on Ubuntu 24.04 provides 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.
You can successfully use Swift on Ubuntu 24.04 by following the installation steps, which expands your development toolkit with the powerful Swift programming language.
Where to install Swift?
The best place to install Swift on Ubuntu 24.04 is directly from the official Swift.org install page, which provides the most up-to-date instructions and toolchains.
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!