Compose SwiftUIv0.3.2
esc
GuideAPIGitHub
Framework

Compose SwiftUI

Write SwiftUI screens in Kotlin with the Compose runtime, and keep your view models.

iOS 17.0+macOS 14.0+tvOS 17.0+watchOS 10.0+

Overview

Compose SwiftUI lets you write SwiftUI screens in Kotlin. It uses the Compose runtime, not Compose UI: your composables build a tree of SwiftUI views, and the app renders them with Apple's SwiftUI. Compose HTML does the same thing for the browser DOM.

Your Kotlin ViewModels, StateFlows and remember state work unchanged. You only rewrite the UI layer.

fun counterScreen() = composeSwiftUI {
    val vm = viewModel { CounterViewModel() }
    val count by vm.count.collectAsState()
    NavigationStack {
        VStack(spacing = 16.0, modifier = Modifier.navigationTitle("Counter")) {
            Image(systemName = SFSymbol.swift, modifier = Modifier.font(Font.largeTitle).foregroundStyle(Color.orange))
            Text("Count: $count", modifier = Modifier.font(Font.title))
            Button("Increment", action = vm::increment)
        }
    }
}
ComposeView { CounterScreenKt.counterScreen() }

Topics

Browse all 3260 APIs · Read the guide