# Kotlin Tooling Native Build Performance

Diagnoses and fixes slow Kotlin/Native compilation and linking in Kotlin Multiplatform...

- Repository: https://github.com/Kotlin/kotlin-agent-skills (1104 stars)
- Category: Mobile
- License: Apache-2.0
- Last updated: 2026-10-30
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add Kotlin/kotlin-agent-skills --skill kotlin-tooling-native-build-performance -g -a claude-code -y`
Codex: `npx skills add Kotlin/kotlin-agent-skills --skill kotlin-tooling-native-build-performance -g -a codex -y`
Cursor: `npx skills add Kotlin/kotlin-agent-skills --skill kotlin-tooling-native-build-performance -g -a cursor -y`
Gemini CLI: `npx skills add Kotlin/kotlin-agent-skills --skill kotlin-tooling-native-build-performance -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add Kotlin/kotlin-agent-skills`

## Description

Diagnoses and fixes slow Kotlin/Native compilation and linking in Kotlin Multiplatform projects that target iOS. Use when the user reports slow iOS or shared-framework builds, long linkDebug*/linkRelease* or XCFramework tasks, cold CI builds that re-download the Kotlin/Native toolchain, KSP or other generated code on the native path, transitiveExport usage, or asks for a local-development versus CI build performance plan.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Kotlin/Native Build Performance

Turn "the iOS build is slow" into a measured diagnosis and a small set of safe
fixes. Two rules apply throughout:

1. Never trade away required release behavior. A faster local loop must not
   change what CI publishes.
2. Measure before and after with the same command and the same build state.
   An unmeasured fix is a guess.

## Step 0: Classify the Slow Scenario

Establish four facts before editing anything: **where** (local or CI),
**what** (debug feedback loop or release/distribution artifact), **state**
(first build, clean, warm, or no-op), and **phase** (which tasks dominate the
log). Then match the dominant symptom:

| Symptom in the build log | Likely cause | Read |
|---|---|---|
| `linkRelease*` or `*ReleaseXCFramework` tasks in a local development loop | Building distribution artifacts for development | [artifacts-and-targets](references/artifacts-and-targets.md) |
| Kotlin/Native compiler distribution downloaded on every CI run | `~/.konan` not preserved between runs | [caching-and-gradle](references/caching-and-gradle.md) |
| Long pause before the first task starts | Configuration phase, no configuration cache | [caching-and-gradle](references/caching-and-gradle.md) |
| All iOS targets build when only one simulator is needed | Broad task (`build`, `assemble`, `assemble*XCFramework`) or unused targets | [artifacts-and-targets](references/artifacts-and-targets.md) |
| `ksp*` tasks ahead of `compileKotlinIos*` | Generated-code work on the native path | [exports-and-generated-code](references/exports-and-generated-code.md) |
| Small source edit recompiles and relinks everything | Compiler caches disabled, or missing incrementality | [caching-and-gradle](references/caching-and-gradle.md), [experimental](references/experimental.md) |
| Machine overloaded while several `link*` tasks run at once | Parallel native linking | [caching-and-gradle](references/caching-and-gradle.md), worker-limit caveat |

The rest: https://github.com/Kotlin/kotlin-agent-skills/blob/HEAD/skills/kotlin-tooling-native-build-performance/SKILL.md
