Calling Kotlin Multiplatform Coroutines from Swift with the help of KMP-NativeCoroutines
summary
Demo app uses Kotlin Multiplatform plus the KMP-NativeCoroutines Gradle plugin to expose suspending functions and flows to Swift as native APIs with no nullable wrappers, fixing generic loss for flows. It generates async/await and Combine friendly bindings, supports AsyncSequence, and demonstrates automatic cancellation when views deinit. Exception handling still requires try/catch because unhandled Kotlin exceptions crash the app. The repository and examples (suspend returns true/false, flows emit 0 1 2 then throw) compile and behave as shown.
AI-written summary · about
chapters (8)
- 0:00Introduction and speaker
- 1:51Three ways to call coroutines
- 6:07Manual wrapper approach
- 7:12KMP NativeCoroutines solution
- 9:18Handling flows in Swift
- 12:26Cancellation and exceptions
- 16:43SwiftUI integration
- 19:52Summary and resources
related talks
41mCoroutines for Kotlin Multiplatform in practise
36mWriting Kotlin Multiplatform libraries that your iOS teammates are gonna love
37mKotlin and Compose Multiplatform patterns for iOS interop
34mKMM survival guide: how to tackle everyday struggles between Kotlin and Swift
36mGoing Multiplatform with Kotlin
29mKMP for Mobile Developers
43mLevel up on Kotlin Multiplatform
35mIntro to Kotlin Multiplatform
