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.
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:
$ eval "$(curl -sL https://apt.vapor.sh)"
curl -L https://repo.vapor.codes/apt/keyring.gpg | sudo apt-key add - echo "deb https://repo.vapor.codes/apt $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/vapor.list sudo apt update sudo apt install swift
For other distros, see :ref:`Extra Credit: Swift on Other Distros`.
If you've gotten Swift working on your favorite distros, feel free to create an issue to mention yours!