It's not exclusive to Apple. Android can also play with Swift.
There was a time when many people's first reaction upon hearing the Swift programming language was that it belonged to Apple and could only be used for developing applications targeting Apple systems.
Now, everything has changed significantly. After the Swift team ported the Swift compiler and its ecosystem to Windows and Linux, developers can now use Swift to develop Android applications and easily share code between iOS and Android.
All of this is thanks to the release of the preview version of the Swift SDK for Android toolkit.
Swift's "Ambition" for Cross - Platform Development
Since its debut in 2014, Swift has been striving to break out of the iOS ecosystem. As the successor to Objective - C, Swift is popular for its security, performance, and modern syntax.
With the addition of Android support, developers can even use an approach similar to SwiftUI for interface development, only needing to adapt to Android's Material Design style. This lowers the threshold for iOS developers to enter the Android field and makes the codebase for multi - platform development more unified.
Actually, the release of this SDK is the work of the Swift Android Working Group, which was established earlier this year.
It is reported that this team consists of Apple engineers and open - source contributors. Their main responsibility is to port Swift's runtime and standard library to the Android architecture while ensuring interoperability with Android NDK and Java.
With the arrival of the preview version of the Swift SDK for Android, some early adopters say that the preview version already supports core functions such as concurrent processing and memory management, which may even have an advantage over Kotlin in some performance - sensitive scenarios.
Of course, there are also many challenges. Android is based on the Java Virtual Machine, and Swift code must be compiled into bytecode or native binaries, which incurs certain overhead. Developers also need to handle API differences, such as replacing UIKit with corresponding Android components. However, the SDK also provides tools to bridge these gaps.
According to the analysis of foreign media 9to5Mac, this move continues Swift's portability concept in server - side and embedded applications.
Guide to Obtaining and Getting Started with the SDK
For developers interested in trying, Swift's official website provides a detailed guide for downloading the SDK and getting started.
Windows users can directly obtain it through the installation package (https://www.swift.org/install/windows/), and Linux and macOS users can also download it separately.
The official also released the "Getting Started Guide" (https://www.swift.org/documentation/articles/swift-sdk-for-android-getting-started.html), which provides methods for running native Swift code on Android devices. The Swift for Android Examples demonstrates the complete application development process.
With the Swift SDK, developers can even migrate existing Swift packages to Android. Statistics show that more than 25% of the packages in the Swift Package Index can already be built on Android, and the community showcase also marks Android compatibility.
To further facilitate the interoperability between Swift and Java, the Swift Working Group also launched the swift - java open - source project (https://github.com/swiftlang/swift - java). It is both a library and a code generator that can automatically generate secure and efficient bindings to achieve seamless interoperability between Swift and Java.
Apple's Move Aims to Prevent Developer Drain
It's easy to imagine that Apple bringing the cross - platform language Swift to Android is undoubtedly offering a choice in the fragmented mobile market.
After all, Android accounts for more than 70% of the global market. This move may encourage more developers to adopt Swift while retaining the value of their skills across platforms. It also puts pressure on cross - platform frameworks like Flutter and React Native, which advocate "write once, run anywhere." However, as emphasized in the Swift.org blog, this SDK focuses more on native performance rather than compromise solutions, which is particularly attractive to efficiency - conscious developers.
Some netizens believe that "this move may be especially useful for enterprise applications, significantly saving the cost of repeated development. But for wide adoption, the SDK needs to be more mature. For example, it is not yet fully integrated with Android Studio, and command - line building skills are essential."
Some developers think that if Swift's Android SDK can be integrated with Xcode for cross - platform debugging, it will be more useful for small teams and independent developers.
Some critics worry that this will make Swift lose its Apple - specific features, but supporters believe that this is a natural evolution of the language.
Overall, compared with previous non - official Swift - on - Android projects, Apple's official endorsement is undoubtedly a game - changer. Although the SDK is still in the preview stage, its impact is far - reaching. Its exploration on Android is likely to change the application development landscape in the next few years.
Reference: https://www.swift.org/blog/nightly-swift-sdk-for-android/
This article is from the WeChat official account "CSDN". Compiled by Tu Min. Republished by 36Kr with permission.