<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Compose · QuickRef</title><link>https://qref.eknath.dev/tags/compose/</link><description>Compose updates from QuickRef</description><language>en-us</language><atom:link href="https://qref.eknath.dev/tags/compose/index.xml" rel="self" type="application/rss+xml"/><lastBuildDate>Sat, 05 Dec 2026 00:00:00 +0000</lastBuildDate><item><title>Compose Multiplatform (CMP)</title><link>https://qref.eknath.dev/programming/compose-multiplatform/</link><guid isPermaLink="true">https://qref.eknath.dev/programming/compose-multiplatform/</guid><pubDate>Sat, 05 Dec 2026 00:00:00 +0000</pubDate><category>compose</category><category>cmp</category><category>kotlin</category><category>multiplatform</category><category>ui</category><category>ios</category><category>calf</category><description>Compose Multiplatform reference: setup, entry points per platform, resources, navigation, and the Calf library for adaptive UI, file picker and permissions.</description><content:encoded><![CDATA[<h2 id="overview">Overview</h2>
<p>Compose Multiplatform (CMP) is JetBrains&rsquo; declarative UI toolkit built on Google&rsquo;s Jetpack Compose. It shares the Compose compiler and runtime and uses the same APIs (<code>@Composable</code>, <code>remember</code>, modifiers, layouts, animation), so Jetpack Compose knowledge carries over, and it runs on Android, iOS, desktop and web from common Kotlin code. It sits on top of <a href="https://qref.eknath.dev/programming/kotlin-multiplatform/">Kotlin Multiplatform</a>.</p>
<p><strong>Latest: Compose Multiplatform 1.13.0</strong> (2026-12-01). It moves to Kotlin 2.4.20 (minimum 2.4.0 for Kotlin/Native, 2.4.20 for Kotlin/JS and Wasm), raises the Android minimum SDK to 24 and needs <code>compileSdk</code> 37.1.</p>
<table>
  <thead>
      <tr>
          <th>Platform</th>
          <th>Stability</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Android</td>
          <td>Stable</td>
      </tr>
      <tr>
          <td>iOS</td>
          <td>Stable</td>
      </tr>
      <tr>
          <td>Desktop (JVM)</td>
          <td>Stable</td>
      </tr>
      <tr>
          <td>Web (Kotlin/Wasm)</td>
          <td>Beta (the official stability page dates from September 2025; check it for the current level)</td>
      </tr>
  </tbody>
</table>
<h2 id="setup">Setup</h2>
<div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-text" data-lang="text"><span style="display:flex;"><span>Start a project   kmp.jetbrains.com (pick Android, iOS, Desktop, Web and &#34;Share UI via Compose Multiplatform&#34;)
</span></span><span style="display:flex;"><span>Ready-made link   https://kmp.jetbrains.com/?android=true&amp;ios=true&amp;desktop=true&amp;web=true&amp;iosui=compose&amp;webui=compose&amp;includeTests=true
</span></span><span style="display:flex;"><span>Mobile only       https://kmp.jetbrains.com/?android=true&amp;ios=true&amp;iosui=compose&amp;includeTests=true
</span></span><span style="display:flex;"><span>IDE               Android Studio or IntelliJ IDEA with the Kotlin Multiplatform plugin
</span></span><span style="display:flex;"><span>Check your Mac    brew install kdoctor &amp;&amp; kdoctor
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-kotlin" data-lang="kotlin"><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic">// shared UI module: build.gradle.kts
</span></span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"></span>plugins {
</span></span><span style="display:flex;"><span>    alias(libs.plugins.kotlin.multiplatform)
</span></span><span style="display:flex;"><span>    alias(libs.plugins.android.kotlin.multiplatform.library)
</span></span><span style="display:flex;"><span>    id(<span style="color:#a5d6ff">&#34;org.jetbrains.compose&#34;</span>)                       <span style="color:#8b949e;font-style:italic">// Compose Multiplatform Gradle plugin
</span></span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"></span>    id(<span style="color:#a5d6ff">&#34;org.jetbrains.kotlin.plugin.compose&#34;</span>)         <span style="color:#8b949e;font-style:italic">// Compose compiler plugin (Kotlin 2.0 and newer)
</span></span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"></span>}
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>kotlin {
</span></span><span style="display:flex;"><span>    sourceSets {
</span></span><span style="display:flex;"><span>        commonMain.dependencies {
</span></span><span style="display:flex;"><span>            implementation(compose.runtime)
</span></span><span style="display:flex;"><span>            implementation(compose.foundation)
</span></span><span style="display:flex;"><span>            implementation(compose.material3)
</span></span><span style="display:flex;"><span>            implementation(compose.components.resources)
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>The wizard generates platform app modules (<code>androidApp</code>, <code>iosApp</code>, <code>desktopApp</code>, <code>webApp</code>) and one shared UI module; every app module calls the shared <code>App()</code> composable. Compose Hot Reload lets you iterate on the UI quickly without restarting the app (the official tutorial runs it from the desktop app).</p>
<p>Keep Kotlin, Compose Multiplatform and your libraries on matching versions: library authors state a Kotlin and Compose pairing (see the Calf compatibility table below).</p>
<h2 id="shared-ui">Shared UI</h2>
<div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-kotlin" data-lang="kotlin"><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic">// commonMain
</span></span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"></span><span style="color:#d2a8ff;font-weight:bold">@Composable</span>
</span></span><span style="display:flex;"><span><span style="color:#ff7b72">fun</span> <span style="color:#d2a8ff;font-weight:bold">App</span>() {
</span></span><span style="display:flex;"><span>    MaterialTheme {
</span></span><span style="display:flex;"><span>        <span style="color:#ff7b72">var</span> <span style="color:#79c0ff">count</span> <span style="color:#ff7b72">by</span> remember { mutableStateOf(<span style="color:#a5d6ff">0</span>) }
</span></span><span style="display:flex;"><span>        Column(<span style="color:#f0883e;font-weight:bold">Modifier</span>.fillMaxSize().padding(<span style="color:#a5d6ff">16.</span>dp)) {
</span></span><span style="display:flex;"><span>            Text(<span style="color:#a5d6ff">&#34;Taps: </span><span style="color:#a5d6ff">$count</span><span style="color:#a5d6ff">&#34;</span>)
</span></span><span style="display:flex;"><span>            Button(onClick = { count<span style="color:#ff7b72;font-weight:bold">++</span> }) { Text(<span style="color:#a5d6ff">&#34;Tap&#34;</span>) }
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><h2 id="entry-points">Entry Points</h2>
<div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-kotlin" data-lang="kotlin"><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic">// Android: androidApp module
</span></span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"></span><span style="color:#ff7b72">class</span> <span style="color:#f0883e;font-weight:bold">MainActivity</span> : ComponentActivity() {
</span></span><span style="display:flex;"><span>    <span style="color:#ff7b72">override</span> <span style="color:#ff7b72">fun</span> <span style="color:#d2a8ff;font-weight:bold">onCreate</span>(savedInstanceState: Bundle?) {
</span></span><span style="display:flex;"><span>        enableEdgeToEdge()
</span></span><span style="display:flex;"><span>        <span style="color:#ff7b72">super</span>.onCreate(savedInstanceState)
</span></span><span style="display:flex;"><span>        setContent { App() }
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-kotlin" data-lang="kotlin"><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic">// iOS: iosMain
</span></span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"></span><span style="color:#ff7b72">fun</span> <span style="color:#d2a8ff;font-weight:bold">MainViewController</span>() = ComposeUIViewController { App() }
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-swift" data-lang="swift"><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic">// iOS: SwiftUI shell in the Xcode project</span>
</span></span><span style="display:flex;"><span><span style="color:#ff7b72">struct</span> <span style="color:#f0883e;font-weight:bold">ComposeView</span>: UIViewControllerRepresentable {
</span></span><span style="display:flex;"><span>    <span style="color:#ff7b72">func</span> <span style="color:#d2a8ff;font-weight:bold">makeUIViewController</span>(context: Context) -&gt; UIViewController { MainViewControllerKt.MainViewController() }
</span></span><span style="display:flex;"><span>    <span style="color:#ff7b72">func</span> <span style="color:#d2a8ff;font-weight:bold">updateUIViewController</span>(<span style="color:#79c0ff">_</span> uiViewController: UIViewController, context: Context) {}
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-kotlin" data-lang="kotlin"><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic">// Desktop: jvmMain
</span></span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"></span><span style="color:#ff7b72">fun</span> <span style="color:#d2a8ff;font-weight:bold">main</span>() = application {
</span></span><span style="display:flex;"><span>    Window(onCloseRequest = <span style="color:#ff7b72;font-weight:bold">::</span>exitApplication, title = <span style="color:#a5d6ff">&#34;App&#34;</span>) { App() }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-kotlin" data-lang="kotlin"><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic">// Web: webApp module
</span></span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"></span><span style="color:#d2a8ff;font-weight:bold">@OptIn</span>(ExperimentalComposeUiApi<span style="color:#ff7b72;font-weight:bold">::</span><span style="color:#ff7b72">class</span>)     <span style="color:#8b949e;font-style:italic">// the web API requires opt-in
</span></span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"></span><span style="color:#ff7b72">fun</span> <span style="color:#d2a8ff;font-weight:bold">main</span>() {
</span></span><span style="display:flex;"><span>    ComposeViewport { App() }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>Compose Multiplatform gives you all Jetpack Compose APIs, but <a href="https://kotlinlang.org/docs/multiplatform/compose-android-only-components.html">some are Android-only</a>. Entry points in depth: <a href="https://kotlinlang.org/docs/multiplatform/compose-multiplatform-entry-points.html">native application entry points</a>. In a larger app, pass platform dependencies into <code>App()</code> as parameters or through dependency injection.</p>
<h2 id="jetpack-libraries-in-common-code">Jetpack Libraries in Common Code</h2>
<div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-text" data-lang="text"><span style="display:flex;"><span>Fully multiplatform from Google   androidx.compose.runtime, androidx.annotation and others: use as is
</span></span><span style="display:flex;"><span>Packaged by JetBrains             Compose UI, Foundation, Material 3, Navigation, Lifecycle, ViewModel
</span></span><span style="display:flex;"><span>                                  published with the Android artifact under one group id: org.jetbrains.androidx.* / org.jetbrains.compose.*
</span></span><span style="display:flex;"><span>Result                            Android uses the original AndroidX library, other targets use the JetBrains build
</span></span><span style="display:flex;"><span>Material 3                        not tied to the Compose Multiplatform version: you can depend on it directly (for example an EAP)
</span></span><span style="display:flex;"><span>Material 3 adaptive               standalone artifacts: org.jetbrains.compose.material3.adaptive
</span></span><span style="display:flex;"><span>Extras from JetBrains             components.resources, components.uiToolingPreview (previews in common code),
</span></span><span style="display:flex;"><span>                                  components.animatedimage, components.splitpane
</span></span></code></pre></div><p>Docs: <a href="https://kotlinlang.org/docs/multiplatform/compose-multiplatform-jetpack-libraries.html">how multiplatform Jetpack libraries are packaged</a>.</p>
<h2 id="resources">Resources</h2>
<p>Shared images, fonts and strings live in <code>composeResources</code> and are accessed through a generated <code>Res</code> class.</p>
<div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-text" data-lang="text"><span style="display:flex;"><span>src/commonMain/composeResources/
</span></span><span style="display:flex;"><span>├── drawable/   images (PNG, JPEG, WebP, bitmap, Android vector XML)
</span></span><span style="display:flex;"><span>├── font/       fonts
</span></span><span style="display:flex;"><span>├── values/     strings.xml
</span></span><span style="display:flex;"><span>└── files/      any other files
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-kotlin" data-lang="kotlin"><span style="display:flex;"><span>Text(stringResource(<span style="color:#f0883e;font-weight:bold">Res</span>.string.app_name))
</span></span><span style="display:flex;"><span>Image(painterResource(<span style="color:#f0883e;font-weight:bold">Res</span>.drawable.logo), contentDescription = <span style="color:#ff7b72">null</span>)
</span></span></code></pre></div><p>Resources read synchronously in the caller thread, except raw files and web resources. Docs: <a href="https://kotlinlang.org/docs/multiplatform/compose-multiplatform-resources.html">resources overview</a>.</p>
<h2 id="navigation">Navigation</h2>
<p>Use Navigation for Compose Multiplatform, or Decompose or Voyager. Docs: <a href="https://kotlinlang.org/docs/multiplatform/compose-navigation-routing.html">navigation and routing</a>.</p>
<h2 id="platform-interop">Platform Interop</h2>
<table>
  <thead>
      <tr>
          <th>Need</th>
          <th>Use</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Native view inside Compose on Android</td>
          <td><code>AndroidView</code></td>
      </tr>
      <tr>
          <td>UIKit view inside Compose on iOS</td>
          <td><code>UIKitView</code></td>
      </tr>
      <tr>
          <td>Swing component inside Compose on desktop</td>
          <td><code>SwingPanel</code></td>
      </tr>
      <tr>
          <td>Platform-specific composable</td>
          <td><code>expect</code>/<code>actual</code> composable, or an interface passed in</td>
      </tr>
      <tr>
          <td>Native-looking dialogs, pickers, permissions, WebView</td>
          <td><a href="https://qref.eknath.dev/programming/compose-multiplatform/#calf-platform-apis-and-adaptive-ui">Calf</a></td>
      </tr>
      <tr>
          <td>iOS look and feel</td>
          <td><a href="https://github.com/alexzhirkevich/compose-cupertino">compose-cupertino</a> (Cupertino widgets)</td>
      </tr>
      <tr>
          <td>Mix with SwiftUI or UIKit</td>
          <td><a href="https://kotlinlang.org/docs/multiplatform/compose-swiftui-integration.html">SwiftUI integration</a>, <a href="https://kotlinlang.org/docs/multiplatform/compose-uikit-integration.html">UIKit integration</a></td>
      </tr>
      <tr>
          <td>Mix with Swing on desktop</td>
          <td><a href="https://kotlinlang.org/docs/multiplatform/compose-desktop-swing-interoperability.html">Swing interoperability</a></td>
      </tr>
      <tr>
          <td>Find a library</td>
          <td><a href="https://klibs.io/">klibs.io</a>: AI-powered search over 5,100+ KMP libraries</td>
      </tr>
  </tbody>
</table>
<h2 id="calf-platform-apis-and-adaptive-ui">Calf: Platform APIs and Adaptive UI</h2>
<p><a href="https://github.com/MohamedRejeb/Calf">Calf</a> (<strong>C</strong>ompose <strong>A</strong>daptive <strong>L</strong>ook &amp; <strong>F</strong>eel, by Mohamed Rejeb, Apache 2.0) lets a Compose Multiplatform app use native UI and platform APIs from common code: adaptive components, a file picker, a WebView and runtime permissions, all behind one Compose API. Latest: <strong>0.14.0</strong> (2026-09-13). Docs: <a href="https://mohamedrejeb.github.io/Calf/installation/">mohamedrejeb.github.io/Calf</a>, live <a href="https://calf-library.netlify.app/">web demo</a>.</p>
<table>
  <thead>
      <tr>
          <th>Artifact</th>
          <th>What it gives you</th>
          <th>Platforms</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>calf-ui</code></td>
          <td>Adaptive UI components</td>
          <td>Android, iOS, Desktop, Web</td>
      </tr>
      <tr>
          <td><code>calf-file-picker</code></td>
          <td>Native file picker and saver</td>
          <td>Android, iOS, Desktop, Web</td>
      </tr>
      <tr>
          <td><code>calf-webview</code></td>
          <td>WebView component</td>
          <td>Android, iOS, Desktop, Web</td>
      </tr>
      <tr>
          <td><code>calf-permissions-*</code></td>
          <td>Runtime permissions, one module per permission</td>
          <td>Android, iOS</td>
      </tr>
      <tr>
          <td><code>calf-cupertino-icons</code></td>
          <td>Cupertino icons everywhere</td>
          <td>Android, iOS, Desktop, Web</td>
      </tr>
      <tr>
          <td>geo, navigation, map, media, notification</td>
          <td>Announced, not released yet</td>
          <td>n/a</td>
      </tr>
  </tbody>
</table>
<h3 id="calf-install">Calf Install</h3>
<div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-kotlin" data-lang="kotlin"><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic">// commonMain dependencies
</span></span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"></span>api(<span style="color:#a5d6ff">&#34;com.mohamedrejeb.calf:calf-ui:0.14.0&#34;</span>)                           <span style="color:#8b949e;font-style:italic">// adaptive UI
</span></span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"></span>implementation(<span style="color:#a5d6ff">&#34;com.mohamedrejeb.calf:calf-file-picker:0.14.0&#34;</span>)      <span style="color:#8b949e;font-style:italic">// file picker
</span></span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"></span>implementation(<span style="color:#a5d6ff">&#34;com.mohamedrejeb.calf:calf-webview:0.14.0&#34;</span>)          <span style="color:#8b949e;font-style:italic">// WebView
</span></span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"></span>implementation(<span style="color:#a5d6ff">&#34;com.mohamedrejeb.calf:calf-permissions-core:0.14.0&#34;</span>) <span style="color:#8b949e;font-style:italic">// permissions base
</span></span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"></span>implementation(<span style="color:#a5d6ff">&#34;com.mohamedrejeb.calf:calf-permissions-camera:0.14.0&#34;</span>) <span style="color:#8b949e;font-style:italic">// plus one module per permission you use
</span></span></span></code></pre></div><p><code>calf-ui</code> must be exported to the iOS framework or it does not work on iOS:</p>
<div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-kotlin" data-lang="kotlin"><span style="display:flex;"><span>kotlin {
</span></span><span style="display:flex;"><span>    targets.filterIsInstance&lt;KotlinNativeTarget&gt;()
</span></span><span style="display:flex;"><span>        .filter { <span style="color:#ff7b72">it</span>.konanTarget.family <span style="color:#ff7b72;font-weight:bold">==</span> <span style="color:#f0883e;font-weight:bold">Family</span>.IOS }
</span></span><span style="display:flex;"><span>        .forEach {
</span></span><span style="display:flex;"><span>            <span style="color:#ff7b72">it</span>.binaries.framework {
</span></span><span style="display:flex;"><span>                export(<span style="color:#a5d6ff">&#34;com.mohamedrejeb.calf:calf-ui:0.14.0&#34;</span>)
</span></span><span style="display:flex;"><span>            }
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><table>
  <thead>
      <tr>
          <th>Kotlin</th>
          <th>Compose Multiplatform</th>
          <th>Calf</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>2.4.20</td>
          <td>1.12.0</td>
          <td>0.14.0</td>
      </tr>
      <tr>
          <td>2.4.10</td>
          <td>1.11.1</td>
          <td>0.13.0</td>
      </tr>
      <tr>
          <td>2.3.20</td>
          <td>1.10.3</td>
          <td>0.12.0, 0.11.0, 0.10.0</td>
      </tr>
      <tr>
          <td>2.2.21</td>
          <td>1.9.2</td>
          <td>0.9.0</td>
      </tr>
  </tbody>
</table>
<p>Calf 0.14.0 is built on Compose Multiplatform 1.12, whose Android artifacts need <code>compileSdk = 37</code> (AGP 9.4 or newer); Calf&rsquo;s own <code>minSdk</code> stays 23. Check the repo&rsquo;s compatibility table before pairing it with a newer Compose Multiplatform.</p>
<h3 id="adaptive-ui">Adaptive UI</h3>
<p>Components that look native on each platform (Material on Android, desktop and web; UIKit on iOS, including the iOS 26 liquid glass style): <code>AdaptiveAlertDialog</code>, <code>AdaptiveBasicAlertDialog</code>, <code>AdaptiveBottomSheet</code>, <code>AdaptiveCircularProgressIndicator</code>, <code>AdaptiveClickable</code>, <code>AdaptiveDatePicker</code>, <code>AdaptiveCompactDatePicker</code>, <code>AdaptiveDateRangePicker</code>, <code>AdaptiveTimePicker</code>.</p>
<div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-kotlin" data-lang="kotlin"><span style="display:flex;"><span><span style="color:#ff7b72">var</span> <span style="color:#79c0ff">showDialog</span> <span style="color:#ff7b72">by</span> remember { mutableStateOf(<span style="color:#ff7b72">false</span>) }
</span></span><span style="display:flex;"><span>Button(onClick = { showDialog = <span style="color:#ff7b72">true</span> }) { Text(<span style="color:#a5d6ff">&#34;Show Alert Dialog&#34;</span>) }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#ff7b72">if</span> (showDialog) {
</span></span><span style="display:flex;"><span>    AdaptiveAlertDialog(          <span style="color:#8b949e;font-style:italic">// native UIAlertController on iOS, Material dialog elsewhere
</span></span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"></span>        onConfirm = { showDialog = <span style="color:#ff7b72">false</span> },
</span></span><span style="display:flex;"><span>        onDismiss = { showDialog = <span style="color:#ff7b72">false</span> },
</span></span><span style="display:flex;"><span>        confirmText = <span style="color:#a5d6ff">&#34;OK&#34;</span>,
</span></span><span style="display:flex;"><span>        dismissText = <span style="color:#a5d6ff">&#34;Cancel&#34;</span>,
</span></span><span style="display:flex;"><span>        title = <span style="color:#a5d6ff">&#34;Alert Dialog&#34;</span>,
</span></span><span style="display:flex;"><span>        text = <span style="color:#a5d6ff">&#34;This is a native alert dialog from Calf&#34;</span>,
</span></span><span style="display:flex;"><span>    )
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>Docs: <a href="https://mohamedrejeb.github.io/Calf/ui/adaptive-alert-dialog/">alert dialog</a>, <a href="https://mohamedrejeb.github.io/Calf/ui/adaptive-bottom-sheet/">bottom sheet</a>, <a href="https://mohamedrejeb.github.io/Calf/ui/adaptive-date-picker/">date picker</a>.</p>
<h3 id="file-picker">File Picker</h3>
<div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-kotlin" data-lang="kotlin"><span style="display:flex;"><span><span style="color:#ff7b72">val</span> <span style="color:#79c0ff">scope</span> = rememberCoroutineScope()
</span></span><span style="display:flex;"><span><span style="color:#ff7b72">val</span> <span style="color:#79c0ff">pickerLauncher</span> = rememberFilePickerLauncher(
</span></span><span style="display:flex;"><span>    type = <span style="color:#f0883e;font-weight:bold">FilePickerFileType</span>.Image,
</span></span><span style="display:flex;"><span>    selectionMode = <span style="color:#f0883e;font-weight:bold">FilePickerSelectionMode</span>.Single,
</span></span><span style="display:flex;"><span>    onResult = { files <span style="color:#ff7b72;font-weight:bold">-&gt;</span>
</span></span><span style="display:flex;"><span>        scope.launch {
</span></span><span style="display:flex;"><span>            files.firstOrNull()<span style="color:#ff7b72;font-weight:bold">?.</span>let { <span style="color:#ff7b72">file</span> <span style="color:#ff7b72;font-weight:bold">-&gt;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#ff7b72">val</span> <span style="color:#79c0ff">bytes</span> = <span style="color:#ff7b72">file</span>.readByteArray()   <span style="color:#8b949e;font-style:italic">// read the picked file on any platform
</span></span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"></span>            }
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>    },
</span></span><span style="display:flex;"><span>)
</span></span><span style="display:flex;"><span>Button(onClick = { pickerLauncher.launch() }) { Text(<span style="color:#a5d6ff">&#34;Open File Picker&#34;</span>) }
</span></span></code></pre></div><p>Pass <code>onError = { error: FilePickerException -&gt; ... }</code> to observe failures; cancelling is not a failure and returns an empty list. <code>FilePickerSettings(title, initialDirectory)</code> customizes the dialog. Docs: <a href="https://mohamedrejeb.github.io/Calf/filepicker/">file picker</a>.</p>
<h3 id="permissions">Permissions</h3>
<p>Permissions are split into one module per permission on purpose: an iOS binary then links only the frameworks it uses, which avoids App Store rejections and unneeded <code>Info.plist</code> usage descriptions. Avoid the umbrella <code>calf-permissions</code> module for iOS releases.</p>
<div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-kotlin" data-lang="kotlin"><span style="display:flex;"><span><span style="color:#ff7b72">val</span> <span style="color:#79c0ff">cameraPermissionState</span> = rememberPermissionState(<span style="color:#f0883e;font-weight:bold">Permission</span>.Camera)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#ff7b72">if</span> (cameraPermissionState.status.isGranted) {
</span></span><span style="display:flex;"><span>    Text(<span style="color:#a5d6ff">&#34;Camera permission granted&#34;</span>)
</span></span><span style="display:flex;"><span>} <span style="color:#ff7b72">else</span> {
</span></span><span style="display:flex;"><span>    Button(onClick = { cameraPermissionState.launchPermissionRequest() }) { Text(<span style="color:#a5d6ff">&#34;Request permission&#34;</span>) }
</span></span><span style="display:flex;"><span>}
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic">// Several at once
</span></span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"></span><span style="color:#ff7b72">val</span> <span style="color:#79c0ff">multiple</span> = rememberMultiplePermissionsState(listOf(<span style="color:#f0883e;font-weight:bold">Permission</span>.Camera, <span style="color:#f0883e;font-weight:bold">Permission</span>.FineLocation))
</span></span><span style="display:flex;"><span><span style="color:#ff7b72">if</span> (!multiple.allPermissionsGranted) {
</span></span><span style="display:flex;"><span>    Button(onClick = { multiple.launchMultiplePermissionRequest() }) { Text(<span style="color:#a5d6ff">&#34;Request permissions&#34;</span>) }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>Modules: <code>core</code>, <code>camera</code>, <code>microphone</code>, <code>gallery</code>, <code>location</code>, <code>background-location</code>, <code>bluetooth</code>, <code>contacts</code>, <code>calendar</code>, <code>notifications</code>, <code>wifi</code>. Add the matching entries to <code>AndroidManifest.xml</code> and the usage descriptions to the iOS <code>Info.plist</code>. Docs: <a href="https://mohamedrejeb.github.io/Calf/permissions/">permissions</a>.</p>
<h3 id="webview">WebView</h3>
<div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-kotlin" data-lang="kotlin"><span style="display:flex;"><span><span style="color:#ff7b72">val</span> <span style="color:#79c0ff">state</span> = rememberWebViewState(url = <span style="color:#a5d6ff">&#34;https://example.com&#34;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>LaunchedEffect(Unit) { state.settings.javaScriptEnabled = <span style="color:#ff7b72">true</span> }   <span style="color:#8b949e;font-style:italic">// needed for evaluateJavaScript
</span></span></span><span style="display:flex;"><span><span style="color:#8b949e;font-style:italic"></span>
</span></span><span style="display:flex;"><span>WebView(state = state, modifier = <span style="color:#f0883e;font-weight:bold">Modifier</span>.fillMaxSize())
</span></span></code></pre></div><p>Wraps <code>WebView</code> on Android, <code>WKWebView</code> on iOS, JavaFX <code>WebView</code> on desktop and an <code>iframe</code> on web. It also offers <code>state.evaluateJavaScript(...)</code> and a <code>cookieManager</code>. Docs: <a href="https://mohamedrejeb.github.io/Calf/webview/">WebView</a>.</p>
<h2 id="troubleshooting">Troubleshooting</h2>
<table>
  <thead>
      <tr>
          <th>Symptom</th>
          <th>Cause</th>
          <th>Fix</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Calf UI crashes or is missing on iOS</td>
          <td><code>calf-ui</code> not exported from the iOS framework</td>
          <td>Add <code>export(&quot;com.mohamedrejeb.calf:calf-ui:&lt;version&gt;&quot;)</code> to the iOS framework block</td>
      </tr>
      <tr>
          <td>Build fails with Kotlin or Compose version errors</td>
          <td>Library built against another Kotlin or Compose version</td>
          <td>Match the library&rsquo;s compatibility table</td>
      </tr>
      <tr>
          <td><code>compileSdk</code> error on Android</td>
          <td>Compose Multiplatform 1.12 and newer need a recent <code>compileSdk</code> (37, 37.1 in 1.13)</td>
          <td>Raise <code>compileSdk</code> and use a matching AGP</td>
      </tr>
      <tr>
          <td>App Store rejects the iOS build for permissions</td>
          <td>Linked permission frameworks the app never uses</td>
          <td>Use per-permission Calf modules, not the umbrella module</td>
      </tr>
      <tr>
          <td>Permission always denied on iOS</td>
          <td>Missing <code>Info.plist</code> usage description</td>
          <td>Add the usage string for that permission</td>
      </tr>
      <tr>
          <td><code>evaluateJavaScript</code> does nothing</td>
          <td>JavaScript is disabled in the WebView</td>
          <td>Set <code>state.settings.javaScriptEnabled = true</code></td>
      </tr>
      <tr>
          <td>Skottie animations stop working after 1.13</td>
          <td>Skottie left the Skiko core binary</td>
          <td>Add <code>org.jetbrains.skiko:skiko-skottie</code> to <code>commonMain</code></td>
      </tr>
  </tbody>
</table>
<h2 id="quick-reference">Quick Reference</h2>
<table>
  <thead>
      <tr>
          <th>Item</th>
          <th>Value</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Plugins</td>
          <td><code>org.jetbrains.compose</code> and <code>org.jetbrains.kotlin.plugin.compose</code></td>
      </tr>
      <tr>
          <td>Android entry</td>
          <td><code>setContent { App() }</code></td>
      </tr>
      <tr>
          <td>iOS entry</td>
          <td><code>ComposeUIViewController { App() }</code></td>
      </tr>
      <tr>
          <td>Desktop entry</td>
          <td><code>application { Window(...) { App() } }</code></td>
      </tr>
      <tr>
          <td>Web entry</td>
          <td><code>ComposeViewport(document.body!!) { App() }</code></td>
      </tr>
      <tr>
          <td>Resources</td>
          <td><code>Res.string.x</code>, <code>Res.drawable.x</code> in <code>composeResources</code></td>
      </tr>
      <tr>
          <td>Calf group id</td>
          <td><code>com.mohamedrejeb.calf</code></td>
      </tr>
  </tbody>
</table>
<h2 id="see-also">See Also</h2>
<ul>
<li><a href="https://kotlinlang.org/docs/multiplatform/compose-multiplatform.html">Get started with Compose Multiplatform</a> - Official documentation start page</li>
<li><a href="https://kotlinlang.org/docs/multiplatform/compose-multiplatform-entry-points.html">Native application entry points</a> and <a href="https://kotlinlang.org/docs/multiplatform/compose-multiplatform-new-project.html">fully shared code tutorial</a></li>
<li><a href="https://klibs.io/">klibs.io</a> - Find Kotlin Multiplatform libraries</li>
<li><a href="https://kmp.jetbrains.com/?android=true&amp;ios=true&amp;iosui=compose&amp;includeTests=true">KMP Wizard, Android and iOS with shared UI</a> - A ready-made starting point; all parameters are listed on the <a href="https://qref.eknath.dev/programming/kotlin-multiplatform/#prefilled-wizard-links">Kotlin Multiplatform</a> page</li>
<li><a href="https://www.jetbrains.com/compose-multiplatform/">Compose Multiplatform</a> and the <a href="https://github.com/JetBrains/compose-multiplatform">GitHub repo</a> with release notes</li>
<li><a href="https://kotlinlang.org/docs/multiplatform/compose-multiplatform-and-jetpack-compose.html">Compose Multiplatform and Jetpack Compose</a></li>
<li><a href="https://kotlinlang.org/docs/multiplatform/supported-platforms.html">Stability of supported platforms</a></li>
<li><a href="https://github.com/MohamedRejeb/Calf">Calf</a> - adaptive UI, file picker, WebView, permissions</li>
<li><a href="https://github.com/alexzhirkevich/compose-cupertino">compose-cupertino</a> - Cupertino widgets</li>
<li><a href="https://qref.eknath.dev/programming/kotlin-multiplatform/">Kotlin Multiplatform</a> and <a href="https://qref.eknath.dev/programming/kotlin/">Kotlin</a></li>
<li><a href="https://qref.eknath.dev/links/android/">Android quick reference</a> - Jetpack Compose, Android CLI and skills</li>
</ul>
]]></content:encoded></item></channel></rss>