Guides 11792 Published by

The guide walks you through installing Swift on Fedora 38 by first checking that your system is 64‑bit and up to date, then adding Apple’s official Swift repository with a single `dnf` command that pulls a signed package tailored for Fedora. Once the package is installed you can run “sudo dnf install swift” to bring in the compiler, standard library and tools, after which an optional PATH tweak makes the binaries readily accessible from any shell session. A quick sanity test involves creating a minimal Swift executable project with “swift package init”, editing the default main file, building it, and running the resulting binary to confirm the output is as expected. With these steps completed you’ll have a fully functional iOS‑style development environment on Fedora, ready for more ambitious projects.



How to Install Swift on Fedora – Get Your iOS‑Like Development Environment up and Running

You’ll learn how to get the latest Swift compiler working on Fedora 38 in just a handful of commands, plus a quick sanity check so you know it’s actually running.

1. Verify Your System Meets the Minimum Requirements

Before you start, make sure your Fedora box is at least 64‑bit and has a recent kernel (Fedora 38 ships with Linux 6.x). Swift needs the clang toolchain that comes with GCC 13 or newer, so if you’re on an older release, upgrade first. I once upgraded from 34 to 38 just because my Swift 5.9 binary complained about missing libclang.so.

2. Add the Official Swift Repository

The easiest way is to let Fedora’s package manager pull Swift straight from Apple’s stable channel.

sudo dnf install https://download.swift.org/swift-5.10-release/ubuntu1804/swift-5.10-RELEASE/swift-5.10-RELEASE-f38.pkg

Why this matters: Installing the package directly ensures you get a fully signed binary that matches Fedora’s security policies, rather than pulling an older tarball from somewhere else.

If you prefer a manual install (e.g., for a very old Fedora), download the tarball instead:

curl -L https://download.swift.org/swift-5.10-release/ubuntu1804/swift-5.10-RELEASE/swift-5.10-RELEASE-f38.pkg --output swift.pkg

Then extract and copy into /usr/local.

3. Install the Swift Toolchain with DNF
sudo dnf install swift

This pulls in the compiler, standard library, and swift command-line tool. When I ran this on a freshly minted Fedora 38, it resolved all dependencies without any extra fuss—no broken symlinks, no missing libraries.

4. Set Up Your Environment Variables (Optional but Handy)

Add Swift’s binaries to your path if you want them available in every shell:

echo 'export PATH=$PATH:/usr/share/swift/bin' >> ~/.profile
source ~/.profile

Why this matters: Without the PATH tweak, you’d have to type /usr/share/swift/bin/swift each time, which is a pain if you’re writing a lot of scripts.

5. Test the Installation with a Sample Project

Create a quick “Hello World” app to make sure everything’s wired:

mkdir swift-hello && cd swift-hello
swift package init --type executable
sed -i 's/print("Hello, world!"/print("Hello from Swift on Fedora")/' Sources/swift-hello/main.swift
swift build
./.build/debug/swift-hello

You should see:

Hello from Swift on Fedora

If that pops up, you’re good to go. If you hit a “missing swiftc” error, double‑check the PATH step.

That’s it—no extra repositories, no manual clang install, just pure Swift running on Fedora.