Kotlin's Swift Export, Seen from an App in Production

Image of the author

Germán Bustamante @germanbustamante

Fuelvo's station detail screen on iOS, a SwiftUI screen whose state comes from a shared Kotlin ViewModel

Kotlin’s Swift Export, Seen from an App in Production

There’s been a lot of news on the Kotlin and Swift side of Kotlin Multiplatform since the summer. Most write-ups cover it from a sample project. This one covers it from Fuelvo, a KMP app with a native SwiftUI interface that’s live on the App Store, and asks a practical question: can I drop the interop libraries the app depends on today?

The news, in order

The IDE change has no effect on Fuelvo: Swift has always been written in Xcode there, and Kotlin in Android Studio. Swift export is the one worth looking at closely.

What Fuelvo uses today, and why

The iOS app consumes the Kotlin :core:presentation module (ViewModels, UI state, navigation) as a framework built by the classic Objective-C exporter. That exporter loses exactly what SwiftUI needs most, and three libraries make up for it. The project’s ADR on this has a table like this one:

What the Objective-C exporter losesCovered by
StateFlow<UIState> arrives as an untyped StateFlowKMP-NativeCoroutines (@NativeCoroutinesState)
suspend becomes a callback whose cancellation never reaches the coroutineKMP-NativeCoroutines
sealed becomes a protocol, with no exhaustive switchSKIE (onEnum(of:))
Kotlin enum becomes an opaque classSKIE
No ViewModel lifetime on iOS (viewModelScope is never cancelled)KMP-ObservableViewModel (@StateViewModel)

It works well. Twelve ViewModel files annotate their state, thirteen SwiftUI views hold a ViewModel with @StateViewModel, and every sealed type is mapped to Swift in a single file, where a new variant in Kotlin becomes a compile error rather than a silent default.

It has a cost, though, and it’s the version lock. All three libraries are pinned to builds made for Kotlin 2.4.0. Updating Kotlin means waiting until all three have published a build for the new version and moving them together. Swift export removes that dependency, because it’s part of the compiler.

Line by line: what Swift export would cover

Against the official Swift export documentation:

The decision, for now

Fuelvo stays on the current stack in production. Swift export is in Alpha, the documentation expects breaking changes, and today it can’t export the classes the whole iOS interface depends on. That’s not a criticism: it’s the order in which JetBrains is shipping features, and each release covers more.

What I’m doing in the meantime:

The direction is clear: Kotlin’s Swift interop is moving into the compiler, and the JetBrains IDEs are focusing on Kotlin while Swift stays in Xcode. For an app in production, getting ready means keeping the interop in a few places and avoiding new dependencies on the Objective-C exporter’s quirks, rather than migrating early.