Swift toolchain for Android

There is now a Swift 5.3 toolchain available to run on most Android devices, ie you can write and compile Swift code on an Android phone or tablet, similar to Swift Playgrounds but not a full IDE. If you have an Android device running 7.0 or later, simply install the Termux app and run pkg install swift. It comes with the Swift package manager and can be used to compile many Swift packages. While this Swift toolchain was available in Termux for 64-bit AArch64 devices since earlier this year, this is the first Swift release to support 32-bit Android ARMv7 devices too.

What may be of more interest is that this entire Swift toolchain was cross-compiled from linux x86_64 and I've been upstreaming my patches that it took to build it. It appears to be working well, as the Swift package manager, which is written in Swift, is also cross-compiled from linux to Android before being run in Termux. Hopefully by the next Swift release in March, it will be straightforward for anyone to generate a cross-compilation SDK for Android, including Foundation and the corelibs. If you'd like to try that out now, follow the instructions in my last link and let me know how it goes.

If you have any problems when using Swift in Termux, please report the issue there (the 32-bit ARMv7 toolchain is brand new and hasn't been tested anywhere as much as the AArch64 one). If you have any questions about this Android port, I can answer them here.

Terms of Service

Privacy Policy

Cookie Policy