In the past weeks I've played around quite a bit with Swift on different distributions (ones that are not "officially" supported, such as OpenSUSE, Fedora, Debian, Arch) and found that Swift actually works really great on all these as long as you pick the correct compatible flavor and install the needed dependencies. Maybe this can help others in the community when trying to figure out how to run Swift on their favorite Linux distribution.
In order to run the Swift SDK you need the correct packages. I also found the needed packages on the distributions that I tested since the naming wasn't quite the same and didn't match the install list from the Swift website, which is to be expected. For convenience I recorded them and they are available in the compatibility matrix below:
swift-bin from AUR used since libcurses.so needs to be patched for Arch
In all this, I also found that the Swiftly tool works great for installing Swift versions and works on all the distributions above (minus Arch Linux, since the installation method uses the AUR instead).
I am sure that it will work on even more distributions (like Debian 10/11, older Linux Mint versions, and so forth) but I did not test those. I only listed here what I tried and had great success in building and running Swift applications. If anyone else has experience using those, let me know!
Thanks all, and have fun in your Swift adventures!
Well, this is really nice to know. I was about to install the flatpak on Tumbleweed, but being able to use the latest release from Swift.org is much nicer.
It seems to be new, it wasn't available when I looked a few months ago, but I found it on a search of Flathub last week.
Also, if you want to compile with --static-swift-stdlib, you'll need to make sure libstdc++ is installed. On Tumbleweed that means sudo zypper in libstdc++-devel .
I haven't tried yet but I can give it a shot. I only expect it to work on 64-bit distro's such as Raspberry Pi OS or Ubuntu. But, I have tried swiftly on Fedora arm64 running inside of a VM on a MacBook M1. It works fine :)
I can't seem to get C++ interop to work, I keep getting an error saying that it can't build Glibc (or Foundation if I import that). Everything else is working great though.
Okay, I find that strange. I was able to use C++ interop with Swift 5.10 on OpenSUSE Leap 15.5 with a private C++ library with Glibc and Foundation included and it builds and runs. I was also able to setup a test project with CXX interop enabled on OpenSUSE Tumbleweed and it compiles and runs as well...
Could this be related to your static linking of swift-stdlib, or a library you are using? I have had issues compiling swift-proto and another library when having CXX interop enabled.
So I sat down and tested a few Raspberry Pi distributions with Swiftly and Swift 5.10 and both Raspberry Pi OS 12 (Bookworm) and 11 (Bullseye) work just fine. For Bookworm I selected the Ubuntu 22.04 Swift version, and for Bullseye I selected the Ubuntu 20.04 version. I also tried the 32-bit (armhf) versions of these distributions, and as expected they do NOT work since both Swiftly and Swift are only built for arm64/aarch64. It would be NICE to have armhf support but we don't have that yet...one thing I've been trying to work towards with the community :)
Okay yeah seems like C++ interop is still pretty buggy in 5.10. For the second issue with --static-swift-stdlib, yesterday I found that the libswiftCxx.a and libswiftCxxStdlib.a static libraries were in the wrong location to be used for static linking. If you move them from usr/lib/swift/linux to usr/lib/swift_static/linux then static linking works:
Not sure if it's worth filing some bugs to get these things fixed for Swift 6.0 or if they're even already fixed. But, ideally it would be nice for all this to be worked out once C++ interop is no longer "experimental".