Swift for Android vs. Kotlin Multiplatform
3 days ago
- #Swift
- #CrossPlatform
- #Kotlin
- Swift for Android is now available as an early developer preview, formalizing years of toolchain hacks for cross-platform development.
- Kotlin Multiplatform (KMP) has been a preferred cross-platform solution for native mobile developers, allowing shared business logic with native UIs.
- The article compares Swift for Android and KMP by building two apps: one powered by Swift for Android (Jetpack Compose) and another by KMP (SwiftUI).
- Swift for Android uses JNI bindings to allow Android apps to call Swift code, while KMP generates Objective-C headers for Kotlin code to be used in iOS.
- Both tools have rough edges, especially at the module boundary, with debugging and IDE context-switching being significant pain points.
- Swift for Android is new and evolving rapidly, with recent updates like async-await compatibility, but it's not yet production-ready.
- KMP is more mature but has its own challenges, particularly when used from iOS due to Objective-C bridging.
- The article suggests waiting for Swift for Android to stabilize before adopting it for production, while KMP remains the safer choice for now.
- The author open-sourced both projects for others to explore and build upon.