Use when you need to know whether a Kotlin Multiplatform change still builds and passes tests on both Android and iOS - "did I break iOS?", before pushing or opening a PR, after editing commonMain, iosMain, expect/actual, Gradle files or the version catalog, when a library change may break the apps that consume it, or when CI fails only on the iOS framework link or the iOS simulator tests.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Kmp Build Check?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/kushpawan-kmp-build-check)
---
name: kmp-build-check
description: Use when you need to know whether a Kotlin Multiplatform change still builds and passes tests on both Android and iOS - "did I break iOS?", before pushing or opening a PR, after editing commonMain, iosMain, expect/actual, Gradle files or the version catalog, when a library change may break the apps that consume it, or when CI fails only on the iOS framework link or the iOS simulator tests.
license: Apache-2.0
compatibility: Kotlin Multiplatform Gradle project with a Gradle wrapper and JDK 17+. Python 3.9+ (standard library only) and git. iOS checks need macOS with the Xcode that matches the Kotlin version (Kotlin 2.5 needs Xcode 27, Apple silicon only) and an iOS simulator runtime. Runs Gradle, which may download dependencies; --base also runs git fetch (turn off with --no-fetch). Optional steps use the Android CLI and the Xcode MCP bridge when installed. Toolchain facts verified December 2026.
metadata:
category: testing
platforms: android, ios
---
# KMP build check
A green Android build proves nothing about iOS. `iosMain`, `actual` declarations, cinterop and the
framework link are compiled only by Kotlin/Native tasks, so an Android-only build passes while the
iOS half is broken. This skill runs each check as its own Gradle invocation and reports every one as
**PASS** (Gradle exited 0), **FAIL** (Gradle exited non-zero) or **NOT RUN** (with the reason).
## When to use
- Before pushing or opening a pull request on a KMP repository.
- After a change to `commonMain`, `iosMain`, `expect`/`actual`, a `build.gradle.kts`, `settings.gradle.kts`
or `gradle/libs.versions.toml`.
- In a library repository: to rebuild the apps that consume the library against your local checkout.
- When the user asks "does it still build on iOS?" or "did I break anything?".
## When not to use
- Writing or fixing tests: use `kmp-testing-patterns`.
- Raising Kover coverage: use `kmp-test-coverage-backfill`.
- UI-test locators and accessibility IDs: use `mobile-accessibility-test-ids`.
- Running the app on a device or simulator to see a change: this skill builds and tests. Its optional
smoke step (Workflow step 7) only records what it saw.
- Bumping Kotlin, AGP, Gradle, Compose Multiplatform or Xcode: use `kmp-toolchain-upgrade`.
- Diagnosing *why* a build fails (linker, KSP, Xcode errors): use `kmp-build-failure-triage`. This skill
reports which check failed and its first error.
- Setting up CI: use `kmp-ci-github-actions`. Reviewing the code itself: use `kmp-code-review`.
## Step 0 - Read the project first
1. **Find the Gradle root**: the directory with `gradlew` and `settings.gradle(.kts)`. A monorepo with
several Gradle roots gets one run per root.
2. **Look for `kmp-build-check.json`** at that root. If it exists, it is the source of truth. Never
replace its tasks with task names from memory.
3. **No config yet?** Propose one (see Workflow step 1). Show it to the user before writing it into
their repository.
4. **Read the CI configuration** (`.github/workflows/`, `.gitlab-ci.yml`, and so on). Prefer the tasks CI
already runs, so that a local PASS predicts a CI pass.
5. **Note which Android plugin each module uses.** It decides the unit-test task name:
| Module setup | Android/JVM unit-test task |
|---|---|
| `com.android.kotlin.multiplatform.library` (`kotlin { android { } }`) | `testAndroidHostTest`, and only if `withHostTest {}` is configured. Host tests are off by default; the source set is `androidHostTest` (was `androidUnitTest`). |
| `com.android.library` + `androidTarget()` (legacy; Kotlin 2.5 warns on every AGP version) | `testDebugUnitTest` |
| `jvm()` target | `jvmTest` (`<name>Test` for `jvm("<name>")`) |
iOS checks use `iosSimulatorArm64` tasks. Compose Multiplatform 1.11+ removed `iosX64`, and Xcode 27
runs only on Apple silicon, so `--detect` never proposes an `iosX64` task and warns when it finds one.
6. **Check the host toolchain.** A wrong Xcode or JDK makes the iOS or Android checks FAIL in a way
that looks like a code break. Compare what is installed with what the build needs:
```bash
grep -nE '^(kotlin|agp|android-gradle|androidGradlePlugin|compose-multiplatform)\b' gradle/libs.versions.toml
grep distributionUrl gradle/wrapper/gradle-wrapper.properties
java -version 2>&1 | head -1 # the JDK Gradle will use unless a toolchain overrides it
xcodebuild -version # macOS only
xcrun simctl list runtimes # macOS only; no iOS runtime -> ios_test checks are NOT RUN
```
| Kotlin | Xcode the Kotlin/Native compiler supports | Gradle range |
|---|---|---|
| 2.5.0 | 27.0 (Apple silicon only) | 8.14–9.8.1 |
| 2.4.0–2.4.21 | 26.4 | 7.6.3–9.7.0 (2.4.20+), 7.6.3–9.5.0 (2.4.0–2.4.10) |
| 2.3.x | 26.0 | 7.6.3–9.3.0 (2.3.20+), 7.6.3–9.0.0 (2.3.0–2.3.10) |
- The Kotlin 2.5 compiler needs JDK 17; AGP 9.5 needs JDK 17 and Gradle 9.6.0 or newer.
- Rows are from the [compatibility guide](https://kotlinlang.org/docs/multiplatform/multiplatform-compatibility-guide.html)
as of December 2026. It also lists the AGP range each Kotlin release was tested with. Re-read it for
newer versions.
- A mismatch still shows as FAIL (Gradle exited non-zero). Say in the report that the cause is the
toolchain, not the change, and send version changes to `kmp-toolchain-upgrade`.
- Without Xcode the iOS checks are NOT RUN. Say so up front, so nobody reads a partial run as a full one.
7. **iOS 27 SDK: check for UIScene.** Built with Xcode 27 (iOS 27 SDK), an app without the UIScene
lifecycle no longer launches, yet every Gradle check still passes. Before an Xcode 27 build, look
at the iOS host app:
```bash
# Run from the iOS host app folder (often iosApp/).
grep -rl "UIApplicationSceneManifest" --include='Info.plist' . # UIKit host with scenes
grep -rnE 'struct [A-Za-z0-9_]+[[:space:]]*:[[:space:]]*App[[:space:]]*\{' --include='*.swift' . # SwiftUI App: scene-based
```
A UIKit `AppDelegate` host with neither match lacks UIScene. Report it as a separate warning next to
the summary line (not as PASS or FAIL), and point to `kmp-swiftui-interop` for the fix.
## Workflow
`<skill-dir>` below is the directory that contains this `SKILL.md`. Run the commands from the Gradle root.
1. **Get a config.**
```bash
python3 <skill-dir>/scripts/run_checks.py --detect gradle # reads ./gradlew tasks --all
python3 <skill-dir>/scripts/run_checks.py --detect static # reads build files only
```
Both modes print a proposal and never overwrite a file. Add `--write` to save it as
`kmp-build-check.json`. The two modes trade accuracy for speed:
| Mode | Strength | Weakness |
|---|---|---|
| `gradle` | Real task names, including those made by convention plugins, flavours and the AGP KMP plugin | Configures the whole build (seconds to minutes). Needs the Android SDK and dependency resolution to succeed. |
| `static` | Instant and offline | Guesses. Blind to convention plugins in `build-logic/`, to flavour names and to CocoaPods task names. |
Review the proposal: pick one flavour's `assemble<Flavour>Debug`, and delete checks CI does not need.
Copy `assets/kmp-build-check.example.json` when you want to write the file by hand. The schema and
the consumer setup are in [references/configuration.md](references/configuration.md).
*Done when* `run_checks.py --validate` prints `valid`.
2. **Dry-run the plan.**
```bash
python3 <skill-dir>/scripts/run_checks.py --dry-run
```
*Done when* every check reads `dry run: would run ./gradlew ...`, or shows a NOT RUN reason that you
understand (no wrapper, consumer not checked out).
3. **Run.** Use a full run before a release or a tag. For day-to-day work, scope the run to the diff:
```bash
python3 <skill-dir>/scripts/run_checks.py # every check
python3 <skill-dir>/scripts/run_checks.py --base main # only what the diff vs origin/main can affect
python3 <skill-dir>/scripts/run_checks.py --json build/kmp-build-check/result.json
```
Checks run one after another. Never start two Gradle builds in the same project at once: they
fight over the same locks and both slow down or time out.
*Done when* the summary line `N PASS, N FAIL, N NOT RUN` is printed.
4. **Read every FAIL.** The table shows the first compiler error (`File.kt:line:col message`), the
first failed test, or Gradle's "What went wrong" text. The full log path is in the JSON `log` field.
Quote that line. Do not paste the whole log.
*Done when* each FAIL has a one-line cause.
5. **Fix only when asked.** This skill reports. If the user asks for a fix, make it, run the failing
task directly (`./gradlew <task>`) until it passes, then run the tool again so the final report
comes from one complete run.
6. **Report.** Give the table, the summary line, and for each NOT RUN its reason and who can close it.
Example: "iOS checks NOT RUN: this machine has no Xcode. CI's macOS job will run them."
Add the toolchain mismatch and UIScene warnings from Step 0, if any.
7. **Optional smoke step: see the app start.** Only when the user wants more than a build. Gradle stays
the source of truth. These tools add evidence, never a PASS.
- **Android CLI** (Google's `android` tool), only if `command -v android` finds it and an emulator
or device is connected. Install the APK that Gradle built rather than asking the CLI to build:
```bash
command -v android || echo "android CLI not installed - smoke step NOT RUN"
android run --apks=<app-module>/build/outputs/apk/debug/<file>.apk # deploy and launch
android layout # JSON UI tree: text, resource-id, content-desc
android screen capture -o build/kmp-build-check/android-screen.png # PNG of the screen
```
- **Xcode MCP bridge** (Xcode 26.3+). If the agent already lists an Xcode MCP server
(`claude mcp list` or `codex mcp list`) and the project is open in Xcode, use its tools to build
the iOS host app. Registering one changes the user's agent configuration, so ask first. Setup:
Xcode > Settings > Intelligence > "Allow External Agents to Use Xcode Tools", then
`claude mcp add --transport stdio xcode -- xcrun mcpbridge`.
Report each as "smoke: launched / did not launch / NOT RUN (reason)", below the summary line.
### What `--base` skips
`--base <branch>` fetches `<remote>/<branch>` and diffs against the merge-base with it. It never uses
the local branch, because a stale or unpushed local `main` changes the diff. Use `--base-ref <ref>`
to diff against an exact ref with no fetch. The diff counts committed, uncommitted and untracked files.
| What changed | Effect |
|---|---|
| Only Android source sets (`androidMain`, `src/main`, `androidHostTest` ...) | iOS checks: NOT RUN |
| Only Kotlin Apple source sets (`iosMain`, `appleMain`, `nativeMain` ...) | Android build and unit tests: NOT RUN |
| Only platform source sets | `compileCommonMainKotlinMetadata`: NOT RUN |
| No build file, dependency, cinterop `.def` or Apple source set | the framework link becomes `compileKotlin<Target>` (faster; it does not link) |
| No build file changed, module layout readable | test tasks run only in the changed modules that have test sources |
| Only docs, CI, scripts, or only Swift / Xcode files | every check: NOT RUN, with that reason |
When the merge-base, the remote branch or the module layout cannot be found or read, the tool runs the
unscoped plan and prints a warning. It never fails open into skipping checks.
## Quick reference
| Flag | Effect |
|---|---|
| `--dry-run` | Print the plan; run nothing |
| `--only android` / `--only ios` | One platform's checks, plus the `any` ones |
| `--base BRANCH` / `--base-ref REF` | Scope the run to the diff (see above) |
| `--json PATH` | Write results as JSON; `-` sends JSON to stdout and the table to stderr |
| `--clean` | Build a temporary git worktree of `HEAD`: committed code only |
| `--init-submodules` | Run `git submodule update --init --recursive` when a submodule is missing |
| `--no-consumers` | Skip the consumer checks |
| `--timeout-minutes N` | Per Gradle run (default 45). A timeout is NOT RUN, never PASS. |
| `--validate` | Check `kmp-build-check.json` and exit |
| `--detect gradle\|static` (+ `--write`, `--force`) | Propose a config |
| Check kind | Typical task | Catches |
|---|---|---|
| common | `compileCommonMainKotlinMetadata` | `commonMain` compile errors, `expect` without `actual` |
| android_build | `:composeApp:assembleDebug`, `compileAndroidMain` | `androidMain`, Android resources, manifest merge |
| unit_test | `testDebugUnitTest`, `testAndroidHostTest`, `jvmTest` | `commonTest` on the JVM, plus Android or JVM test sets |
| ios_link | `linkDebugFrameworkIosSimulatorArm64` | `iosMain`, `actual`s, cinterop, linker flags, exported API |
| ios_test | `iosSimulatorArm64Test` | `commonTest` and `iosTest` on Kotlin/Native |
Exit status: `0` no FAIL, `1` at least one FAIL, `2` bad usage or config. Exit 0 with NOT RUN checks
is not "all green".
## Verify
```bash
python3 <skill-dir>/scripts/run_checks.py --validate
python3 <skill-dir>/scripts/run_checks.py --json -
python3 -m unittest discover -s <skill-dir>/scripts -p "test_*.py" # the tool's own tests
```
Reporting rules:
- A check is **PASS** only when its Gradle process exited 0. The tool never reads log text to decide
a pass.
- Every **NOT RUN** carries its reason. Some reasons are about the environment: no Xcode, not macOS,
no simulator runtime, no Android SDK, an uninitialised submodule, a timeout, or a consumer that is
not checked out. Others are about scope: the diff does not reach the check, or `--only` filtered it.
- Quote the summary line verbatim. Never say "everything passes" while any check is NOT RUN. Name the
checks that did not run.
- If CI runs the iOS half on macOS runners, say that CI can close the gap. Do not imply it has.
## Common mistakes
| Mistake | Why it bites | Fix |
|---|---|---|
| Treating `assembleDebug` as "it builds" | Kotlin/Native never compiled `iosMain` or linked the framework | Keep an iOS link check in every config |
| Task names from memory | A missing task FAILs and looks like a real break (`testAndroidHostTest` vs `testDebugUnitTest`) | `--detect gradle`, or `./gradlew <module>:tasks --all` |
| Diffing against a local `main` | Unpushed or stale commits hide or add changes | `--base main` always uses the fetched `origin/main` |
| Untracked `.kt` files in the working tree | The build passes locally; the commit does not compile in CI | Commit them, or run with `--clean` |
| Reporting NOT RUN as passed | The iOS half was never compiled | Name every NOT RUN and its reason |
| Using `--base` right before a release | The link is downgraded to a compile for common-only diffs | Run unscoped before tagging |
| Checking a library change by building the app normally | The app resolves the *published* artifact, not your edit | Add a consumer with a substitution property ([references/configuration.md](references/configuration.md)) |
| AGP KMP library plugin without `withHostTest {}` | `commonTest` never runs on the JVM side, so no unit-test task exists | Add `withHostTest {}` in the module's `android {}` block |
| `iosArm64Test` as the iOS test task | Device-target test binaries cannot run on the Mac | Use `iosSimulatorArm64Test` |
| Keeping `iosX64Test` or an `iosX64` link check | Compose Multiplatform 1.11+ removed `iosX64`; Xcode 27 runs only on Apple silicon | `iosSimulatorArm64` tasks; drop `iosX64()` |
| Kotlin 2.5 built with Xcode 26.x, or Kotlin 2.4 with Xcode 27 | Kotlin/Native supports one Xcode per release line; the iOS checks FAIL for the toolchain, not the code | Match the Step 0 table; route bumps to `kmp-toolchain-upgrade` |
| JDK 11 on `PATH` | Kotlin 2.5's compiler and AGP 9.5 need JDK 17 | Point `JAVA_HOME` at JDK 17 or newer |
| Calling an Xcode 27 build green without checking UIScene | Gradle passes; the app no longer launches on the iOS 27 SDK | Run the Step 0 UIScene check and report it |
| Reporting the Android CLI smoke step as PASS | It proves the app launched once, not that the build is sound | Keep it below the summary line as evidence |
| Two builds in one project at once | Gradle lock contention; one build waits, then times out | Run checks sequentially (the tool does) |
## Related skills
- `kmp-testing-patterns`: write the tests these checks run.
- `kmp-test-coverage-backfill`: raise coverage after the build is green.
- `mobile-accessibility-test-ids`: stable locators for UI and end-to-end tests.
- `kmp-build-failure-triage`: diagnose a FAIL this skill reports.
- `kmp-ci-github-actions`: run the same checks on CI runners, including macOS for iOS.
- `kmp-toolchain-upgrade`: move Kotlin, AGP, Gradle, Compose Multiplatform and Xcode together.
- `kmp-swiftui-interop`: adopt the UIScene lifecycle in the iOS host app.
- [android/skills](https://github.com/android/skills): official Android agent skills, including
[android-cli](https://github.com/android/skills/tree/main/devtools/android-cli).
- [Giving external agents access to Xcode](https://developer.apple.com/documentation/xcode/giving-external-agents-access-to-xcode):
Apple's `xcrun mcpbridge` setup.
- [kotlin-tooling-native-build-performance](https://github.com/Kotlin/kotlin-agent-skills/tree/main/skills/kotlin-tooling-native-build-performance):
when the iOS link checks are slow.
- [skydoves/android-testing-skills](https://github.com/skydoves/android-testing-skills): Android testing skills.