Simple library for observing Jetpack Compose’s snapshot state in your SwiftUI views.


Put SnapshotBridge.kt into your Kotlin iOS source set, ComposeStateObserver.swift into your Swift codebase that consumes your Kotlin code, and then just call ComposeStateObserver from your SwiftUI views. Any snapshot state objects read in the closure passed to ComposeStateObserver will be tracked and the body of the ComposeStateObserver will re-render when those objects are changed.

All the usual rules about snapshot state read tracking apply: the reads can happen at any depth in the call stack.


Given this model class defined in Kotlin:

class Counter {
    var value by mutableStateOf(0)
        private set

    fun increment() {

A SwiftUi view could consume it like this:

struct App: View {
    @StateObject var counter = Counter()

    var body: some View {
        ComposeStateObserver {
            Button {
            } label: {
                Text("Counter: \(counter.value)")

See the swiftdoc on ComposeStateObserver for more information.

Related links


View Github