From Kotlin to Native and back: accessing native macOS API in Compose Multiplatform
Abstract:
Compose Multiplatform makes it easy to build cross-platform desktop apps with Kotlin and Compose, but what about native APIs, like iCloud on macOS? Accessing such APIs isn't possible through the regular Compose Multiplatform toolchain. However, with a bit of "magic", we can turn dreams (or feature requests) into reality.In this talk, we'll explore how to combine Kotlin/Native and the JNI (Java Native Interface) to bridge the gap between a JVM-based UI and native system features. We'll write Kotlin code, compile it into a native library, and call it back from Kotlin.
You'll learn how to build Kotlin/Native code into a native macOS dynamic library and integrate it into a Compose Multiplatform desktop app, unlocking access to iCloud and enabling features like backup and restore for your app’s data.
Slides:
Resources:
FeedFlow
https://feedflow.dev/Java Native Interface
https://docs.oracle.com/javase/8/docs/technotes/guides/jni/Java Native Access (JNA)
https://github.com/java-native-access/jnaProject Panama: Interconnecting JVM and native code
https://openjdk.org/projects/panama/Kevin Galligan’s post
https://bsky.app/profile/kpgalligan.bsky.social/post/3lcgoc32zf22cNSFileManager
https://developer.apple.com/documentation/foundation/filemanager?language=objcURLsForDirectory:inDomains:
https://developer.apple.com/documentation/foundation/filemanager/urls(for:in:)?language=objcDefinition file
https://kotlinlang.org/docs/native-definition-file.htmlNative distributions - Adding files to packaged application
https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-native-distribution.html#adding-files-to-packaged-applicationAccessing native macOS API in Compose Multiplatform
https://www.marcogomiero.com/posts/2025/compose-desktop-macos-api-jni/