How to Install Swift on Ubuntu 24.04
Installing Swift on Ubuntu 24.04 lets you run Apple’s programming language on a Linux computer. Swift is a free coding language that handles everything from server backends to mobile applications.
Ubuntu 24.04 runs Swift natively so you can write and test code directly on your Linux desktop or server. Setting up the official tools takes just a few terminal commands.
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
Target systems running Ubuntu 24.04 (also called ‘noble’) require proper preparation before running the installer. Confirming the exact operating system build prevents compatibility errors down the line.
Download the appropriate release package matching the target environment architecture.
Run the command to verify the Ubuntu release and codename of your system.
lsb_release -a
Systems running Ubuntu 24.04 return release version 24.04 alongside the noble codename.
Fetch the required dependency packages using the system package manager.
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
Grabbing the Swift 6.0.3 binary requires the wget file retrieval utility. Fetching the latest release version from the official Swift download site ensures the installer matches current platform updates.
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
Grabbing the GPG key (a cryptographic signature used to verify package authenticity) secures the installation process. 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
Extract the downloaded installer archive and move the resulting folder 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
Exposing executable binaries to the shell requires appending the installation directory to the system PATH variable. Appending the bin directory via the echo utility makes the toolset globally accessible. Executing source $HOME/.profile loads the new configuration immediately.
echo "export PATH=$PATH:/opt/swift/usr/bin" >> $HOME/.profile
source $HOME/.profile
Executing the command below confirms the compiler binary responds correctly.
swift --version
The terminal outputs the specific compiler version currently active in the environment.
Launching the interactive read-eval-print loop starts the Swift REPL environment.
swift
That completes the setup process.
Conclusion:
Installing Swift on Ubuntu 24.04 provides a powerful tool for cross-platform development. Key benefits include:
- 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.
Completing these configuration steps expands the local development toolkit with Apple's modern programming language on Linux.
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!