Published on February 2, 2016 也可以阅读中文版
Update: Issue #2 now available here.
Tomorrow will mark the first two months since the opensource release of Swift.
A lot has happened in this short period of time, the community has been involved in every step of the evolution of the language, contributing code for the various Swift sub-projects and even discussing the future of the language drafting proposals for improvement. Apple was extremely open to community participation and the community responded with a lot of contributions and ideas.
In these two months, the area where the community really shined was, in my opinion, the porting to new platforms.
There are currently a few parallel community-driven and cross-pollinating projects that will make Swift available on new operating systems (Android, Linux ARM, FreeBSD, Windows).
Let’s recap each project status, from now on I will post semi-periodic updates on these projects, if interested, you can subscribe below.
ARMv7 and ARMv6
The Linux ARM port is the result of the efforts of William Dillon, @tienex and others. It’s in an advanced state of completion, the only user facing things that don’t work yet are the REPL(still a few issues) and SwiftPM.
The JIRA issue you can track to follow further developments is SR-40. The port has been merged into master a few days ago, and the history of how this port came to be can be reconstructed from William’s Blog and from Github issues #439 and #901. A lot of work (and time spent compiling) was involved with this port, congrats to all the developers involved.
As we speak, development is at the moment focused on replacing the linker
swift.ld with a more portable solution, see #1157.
Do you want to try this port on your Raspberry Pi 2, BeagleBone Black or another ARMv7 board?
Well, Joe Bell from achieved.it has you covered. He kindly provides convenient ARM debian packages and with those you should be ready to go in a few minutes. His site has also a lot of interesting Glibc tutorials and guides, all this together makes the Linux ARM port the easiest one to start with.
What about pre-compiled ARMv6 binaries for the Raspberry Pi 1/Zero? Get them here.
We all started considering running Swift code on Android devices way before Swift was made opensource and the first successful attempt was described in a post from Romain Goyet, that leveraging what LLVM offers and with some manual steps using the NDK, built a little sample Android app that used some native code that was in origin written in Swift.
Nowadays, all the work aimed at building a real Swift Android port is collected in the SwiftAndroid Github organization and is the result of the concerted efforts of Zhuowei Zhang, Brian Gesiak, @ephemer and others. Among their projects you’ll find all you need to build a Linux toolchain and build your first application following Zhuowei’s example.
The group has also an additional ongoing activity (#13) that has the objective to build a OSX/Android cross-compiling toolchain, to be able to compile Swift without using intermediate Linux hosts. The issues page keeps tracks of what everyone is working on.
Other than the main repository with the port, the organization has also some subprojects:
- swift-android-extras - A collection of script to build the toolchain.
- swift-jni - A JNI wrapper to link the Swift code compiled to native with the Java side of an Android application.
- swift-android-gradle - A Gradle plugin.
- swift-android-samples - Some samples to test the toolchain.
If you want to try this out, keep in mind that this port requires a fix for a bug in the FreeBSD runtime linker that is available only in FreeBSD-CURRENT.
The port is still young and needs feedback, if you want to keep track of it the best way to do it is to follow the discussions on the swift-dev mailing list and check Davide commits when they land on master.
The Windows port (that uses Cygwin) by Han Sangjin even if it’s one of the youngest ports can already compile and run a simple hello world. Other components like the REPL do not work yet.
Did you like this article? Follow me on Twitter!