Dan Tech Academy

Compose Multiplatform: one UI for Android and iOS, what you can share and what you can't

Which parts of a Compose Multiplatform app you write once for Android and iOS, and which stay per platform: entry points, configuration, OS APIs and native views.

What Compose Multiplatform is

Compose Multiplatform is the multiplatform version of Jetpack Compose, built by JetBrains. You write composables in commonMain, and the same code runs on Android and iOS.

JetBrains announced Compose Multiplatform for iOS as Stable in version 1.8.0, on May 6, 2025. At the time of writing, the latest stable release is 1.12.2. I built the code in this post on Compose Multiplatform 1.11.1 with Kotlin 2.4.10.

The practical question when you start is which parts you write once for both platforms and which parts you still write per platform.

What you can share

A screen written in commonMain:

// commonMain
package com.example.cmp

import androidx.compose.foundation.layout.Column
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue

@Composable
fun ScoreBoard(score: Int, onAdd: () -> Unit) {
    Column {
        Text("Score: $score")
        Button(onClick = onAdd) {
            Text("+1")
        }
    }
}

@Composable
fun App() {
    MaterialTheme {
        var score by remember { mutableIntStateOf(0) }
        ScoreBoard(score = score, onAdd = { score++ })
    }
}

This is ordinary Compose. remember, state, Column and Material 3 all work in shared code. According to the comparison table in the Kotlin docs, these libraries also have versions you can use from shared code:

  • Jetpack Lifecycle and ViewModel.
  • Navigation Compose.
  • Resources: strings, images and fonts placed in composeResources and accessed through the Res class, instead of Android's R class.

When you build for Android, Gradle uses the Jetpack Compose artifacts published by Google. For example, compose.material3 becomes androidx.compose.material3:material3 on Android and org.jetbrains.compose.material3:material3 on other targets. Your Android app still runs real Jetpack Compose.

What you still write per platform

The app entry point. Android needs an Activity:

// androidMain
class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent { App() }
    }
}

iOS needs a UIViewController that wraps Compose, which the Swift app then shows:

// iosMain/kotlin/com/example/cmp/MainViewController.kt
fun MainViewController() = ComposeUIViewController { App() }
// iosApp, SwiftUI
import SwiftUI
import Shared

struct ComposeView: UIViewControllerRepresentable {
    func makeUIViewController(context: Context) -> UIViewController {
        MainViewControllerKt.MainViewController()
    }

    func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
}

Shared is the framework name the shared module exports, set by baseName in Gradle. The class name MainViewControllerKt comes from the Kotlin file name.

App configuration. AndroidManifest.xml, Info.plist, camera or location permissions, icons and the splash screen stay in each platform's project. One iOS key is easy to miss: the Kotlin docs require CADisableMinimumFrameDurationOnPhone in Info.plist to enable high refresh rates, and without it the app crashes at runtime.

Operating system APIs. Clipboard, camera, push notifications, Sign in with Apple or Google, and so on. You reach them through expect/actual or through an interface with a separate implementation per platform.

Native views. Some things only exist as native views. On iOS, UIKitView embeds a UIView inside the Compose tree. The Kotlin docs show it with Apple's map view:

// iosMain
UIKitView(
    factory = { MKMapView() },
    modifier = Modifier.size(300.dp),
)

It also works the other way: you can embed a Compose screen in an existing SwiftUI or UIKit app. That lets you bring Compose in one screen at a time instead of rewriting the whole app.

Check third-party libraries early. For example, the Kotlin docs table lists Google's Maps Compose as available for Jetpack Compose only, not for Compose Multiplatform. Before you pick a library, look it up on klibs.io to see whether it supports iOS.

What the UI looks like on iOS

Compose Multiplatform draws its UI itself with Skia. It does not turn composables into UIKit views, so a Material 3 button on iOS is still a Material 3 button. If you want the app to look like iOS, that is the job of a design system you build, not something the framework does for you.

According to the 1.8.0 announcement, JetBrains worked on making the behavior match iOS: scrolling that follows iOS physics, native text selection and editing, back gestures, and support for VoiceOver and the system font size.

A tidy way to split the code

A common split:

  • commonMain: screens, ViewModels, state, logic, resources.
  • androidMain and iosMain: entry points, implementations of interfaces that need OS APIs, and a few native views if any.
  • androidApp and iosApp: each platform's project, holding the app configuration.

The thinner each platform's own part is, the fewer places the two apps can behave differently.

Keep learning

Kotlin Mobile 101 teaches Kotlin and Compose Multiplatform fundamentals on a complete app that runs on a real device.

Reading is fun. A roadmap gets you there.

The Kotlin Android Roadmap sorts the Android Mastery, OOP and Design Patterns posts into 5 levels - from your first line of Kotlin to an app on the store.

Plus a new post every week. Unsubscribe anytime.