
Write native SwiftUI using composable syntax and state-driven UI, with generated typed bindings and a thin Swift bridge; Compose Runtime schedules updates while SwiftUI renders.
Write native SwiftUI in Kotlin.
Compose syntax. Kotlin state. Apple-rendered controls.
English · 简体中文
SwiftUI Kotlin Binding lets you build Apple-native interfaces with Kotlin Composables. Kotlin owns the layout, styling, state, and behavior; a small generated bridge calls official SwiftUI APIs. Compose Runtime manages composition and updates, while SwiftUI measures and draws the interface.
Real screenshots of the Kotlin/Native applications. Click an image to explore its sample.
| CapyTimer | Liquid Glass |
|---|---|
![]() A compact focus panel with a progress ring, tasks, and editable notes. |
![]() Six dark themes, a mesh backdrop, a frosted card, and an icon made from Kotlin-defined paths and gradients. Both samples use local mock data and native controls. Original projects and MIT notices are credited in their directories. |
@Composable, manage state with remember, and handle actions in Kotlin.NSHostingView hosts the composed tree. State changes update existing nodes.On an Apple Silicon Mac with Xcode and an arm64 JDK 21:
git clone https://github.com/zly2006/swiftui-kotlin-binding.git
cd swiftui-kotlin-binding
export JAVA_HOME="$(/usr/libexec/java_home -v 21 -a arm64)"
./gradlew :samples:liquid-glass:linkDebugExecutableMacosArm64
./samples/liquid-glass/build/bin/macosArm64/debugExecutable/LiquidGlassMock.kexe --darkFor CapyTimer, use :samples:capytimer:linkDebugExecutableMacosArm64 and CapyTimerMock.kexe in that sample's build directory.
Version 0.1.0 is available from Maven Central; use its release guide for that API. The examples below use the current source API with Compose Modifier (0.2.0-SNAPSHOT).
After cloning this repository, add includeBuild("../swiftui-kotlin-binding") to your application’s settings.gradle.kts, adjusting the path to your checkout.
Use Kotlin 2.4.0, the Kotlin Compose compiler plugin, and a macosArm64() target. Add the runtime dependency:
repositories { mavenCentral() }
kotlin {
macosArm64()
sourceSets.commonMain.dependencies {
implementation("me.zly2006.swiftui:swiftui-compose:0.2.0-SNAPSHOT")
}
}The macOS bridge and its native static library resolve transitively. You do not need to generate bindings or copy a Swift library to consume the release.
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import me.zly2006.swiftui.nativeui.*
@Composable
fun Counter() {
var count by remember { mutableStateOf(0) }
VStack(spacing = 12.0, modifier = Modifier.padding(24.0)) {
Text("Count: $count", Modifier.font(Font.TextStyle.headline))
Button(onClick = { count++ }) { Text("Increment") }
}
}Host this content in a macOS window with MacosNativeUiBackend and NativeComposition. See the complete getting started guide for project configuration, a window entry point, and lifecycle cleanup.
Kotlin @Composable + state
↓
Compose Runtime → incremental native node updates
↓
Generated typed C ABI → thin Swift forwarding
↓
Official SwiftUI → one native window host
| Module | Responsibility |
|---|---|
swiftui-compose |
Public Kotlin Composables, Compose Runtime integration, updates, callbacks, and ownership. This is the dependency applications use. |
swiftui-bridge |
Native interoperability, SwiftUI hosting, resource management, and the embedded Swift static library. |
swiftui-codegen |
Repository build tool for generation from the component whitelist and typed semantic model; not published to Maven. |
samples |
Independent Kotlin UI examples and macOS test hosts. |
Kotlin chooses the UI and its parameters. Swift forwards official API calls; it contains no application pages or business state. The rendering path uses Compose Runtime, with no Skia drawing host.
0.1.0 is an early release for macOS on Apple Silicon. Native APIs target macOS 15 or later. Build applications with Kotlin 2.4.0 and a compatible Apple toolchain; this release was tested on macOS 26 with Xcode 26.
The JVM target supports public API compilation and runtime tests; it does not render Apple UI. iOS, Intel macOS, and full SwiftUI API coverage are future work. Native rendering is intended to retain the platform's resource advantages; comparative CPU and memory benchmarks remain to be completed.
Contributions to API coverage, native behavior, and documentation are welcome. Follow the project constraints and run:
./gradlew :swiftui-codegen:test :swiftui-compose:jvmTestThe library is licensed under GPL-3.0-only. See LICENSE. The CapyTimer and Liquid Glass adaptations retain their upstream MIT licenses and credits in their respective sample directories.
Write native SwiftUI in Kotlin.
Compose syntax. Kotlin state. Apple-rendered controls.
English · 简体中文
SwiftUI Kotlin Binding lets you build Apple-native interfaces with Kotlin Composables. Kotlin owns the layout, styling, state, and behavior; a small generated bridge calls official SwiftUI APIs. Compose Runtime manages composition and updates, while SwiftUI measures and draws the interface.
Real screenshots of the Kotlin/Native applications. Click an image to explore its sample.
| CapyTimer | Liquid Glass |
|---|---|
![]() A compact focus panel with a progress ring, tasks, and editable notes. |
![]() Six dark themes, a mesh backdrop, a frosted card, and an icon made from Kotlin-defined paths and gradients. Both samples use local mock data and native controls. Original projects and MIT notices are credited in their directories. |
@Composable, manage state with remember, and handle actions in Kotlin.NSHostingView hosts the composed tree. State changes update existing nodes.On an Apple Silicon Mac with Xcode and an arm64 JDK 21:
git clone https://github.com/zly2006/swiftui-kotlin-binding.git
cd swiftui-kotlin-binding
export JAVA_HOME="$(/usr/libexec/java_home -v 21 -a arm64)"
./gradlew :samples:liquid-glass:linkDebugExecutableMacosArm64
./samples/liquid-glass/build/bin/macosArm64/debugExecutable/LiquidGlassMock.kexe --darkFor CapyTimer, use :samples:capytimer:linkDebugExecutableMacosArm64 and CapyTimerMock.kexe in that sample's build directory.
Version 0.1.0 is available from Maven Central; use its release guide for that API. The examples below use the current source API with Compose Modifier (0.2.0-SNAPSHOT).
After cloning this repository, add includeBuild("../swiftui-kotlin-binding") to your application’s settings.gradle.kts, adjusting the path to your checkout.
Use Kotlin 2.4.0, the Kotlin Compose compiler plugin, and a macosArm64() target. Add the runtime dependency:
repositories { mavenCentral() }
kotlin {
macosArm64()
sourceSets.commonMain.dependencies {
implementation("me.zly2006.swiftui:swiftui-compose:0.2.0-SNAPSHOT")
}
}The macOS bridge and its native static library resolve transitively. You do not need to generate bindings or copy a Swift library to consume the release.
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import me.zly2006.swiftui.nativeui.*
@Composable
fun Counter() {
var count by remember { mutableStateOf(0) }
VStack(spacing = 12.0, modifier = Modifier.padding(24.0)) {
Text("Count: $count", Modifier.font(Font.TextStyle.headline))
Button(onClick = { count++ }) { Text("Increment") }
}
}Host this content in a macOS window with MacosNativeUiBackend and NativeComposition. See the complete getting started guide for project configuration, a window entry point, and lifecycle cleanup.
Kotlin @Composable + state
↓
Compose Runtime → incremental native node updates
↓
Generated typed C ABI → thin Swift forwarding
↓
Official SwiftUI → one native window host
| Module | Responsibility |
|---|---|
swiftui-compose |
Public Kotlin Composables, Compose Runtime integration, updates, callbacks, and ownership. This is the dependency applications use. |
swiftui-bridge |
Native interoperability, SwiftUI hosting, resource management, and the embedded Swift static library. |
swiftui-codegen |
Repository build tool for generation from the component whitelist and typed semantic model; not published to Maven. |
samples |
Independent Kotlin UI examples and macOS test hosts. |
Kotlin chooses the UI and its parameters. Swift forwards official API calls; it contains no application pages or business state. The rendering path uses Compose Runtime, with no Skia drawing host.
0.1.0 is an early release for macOS on Apple Silicon. Native APIs target macOS 15 or later. Build applications with Kotlin 2.4.0 and a compatible Apple toolchain; this release was tested on macOS 26 with Xcode 26.
The JVM target supports public API compilation and runtime tests; it does not render Apple UI. iOS, Intel macOS, and full SwiftUI API coverage are future work. Native rendering is intended to retain the platform's resource advantages; comparative CPU and memory benchmarks remain to be completed.
Contributions to API coverage, native behavior, and documentation are welcome. Follow the project constraints and run:
./gradlew :swiftui-codegen:test :swiftui-compose:jvmTestThe library is licensed under GPL-3.0-only. See LICENSE. The CapyTimer and Liquid Glass adaptations retain their upstream MIT licenses and credits in their respective sample directories.