Unfortunately, the official Swift binaries only work on Ubuntu, and they’re standalone binaries independent of any package manager. Here are steps on getting it to work on various distros/package tools.

The easiest way to get started using Swift is via the Flatpak repo. Make sure you’ve followed the official Flatpak setup instructions.

First, make sure you have the Freedesktop SDK installed:

$ flatpak --user install flathub org.freedesktop.Sdk

Add the Flatpak remote:

$ flatpak --user remote-add swift https://swift-flatpak.refi64.com/swift.flatpakrepo # Or, if you prefer to add it manually: curl -sSL https://gpg.refi64.com/swift-flatpak | flatpak --user remote-add --gpg-import=- swift http://swift-flatpak.refi64.com

Then, install the SDK extension and live SDK:

$ flatpak --user install swift org.freedesktop.Sdk.Extension.swift4 org.freedesktop.Sdk.Extension.swift4.live

In order to run the Swift compiler via the Flatpak, you’ll need to use this command:

$ flatpak run -d org.freedesktop.Sdk.Extension.swift4.live swift ...

To shorten this, define an alias:

$ alias swiftpak='flatpak run -d org.freedesktop.Sdk.Extension.swift4.live swift'

Now, you can just use swiftpak: