kotlin-tooling-native-build-performance

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

1.0k|41|Updated Mar 13, 2026
One-click install
npx skills add https://github.com/Kotlin/kotlin-agent-skills --skill kotlin-tooling-native-build-performance
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-tooling-native-build-performance
Source: https://github.com/Kotlin/kotlin-agent-skills/tree/main/skills/kotlin-tooling-native-build-performance
Command: npx skills add https://github.com/Kotlin/kotlin-agent-skills --skill kotlin-tooling-native-build-performance

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Kotlin/Native builds for iOS targets are often slow due to misconfigured caches, release artifacts built during local development loops, broad framework exports, and cold CI environments that re-download the Kotlin/Native toolchain. This Skill turns a vague "the iOS build is slow" complaint into a measured diagnosis and a small set of safe fixes that never compromise release behavior.

Core Features & Use Cases

  • Static Build Audit: Runs a read-only shell script that scans Gradle properties, build scripts, and CI workflows for known performance problems such as disabled compiler daemons, missing configuration cache, transitiveExport usage, and uncached ~/.konan directories.
  • Guided Diagnosis Workflow: Classifies the slow scenario by location (local/CI), build type (debug/release), state (cold/warm), and dominant phase, then maps symptoms in the build log to the right fix reference.
  • Safe Fix Ordering: Applies fixes in a strict sequence — restore caching defaults, narrow local tasks to debug-only targets, cut export and KSP generated-code cost, and only then consider experimental switches with user agreement.
  • Use Case: A developer waits 12 minutes for every shared-module change because their loop runs assembleXCFramework. The Skill identifies that ~690s goes to linkRelease tasks, replaces the local command with linkDebugFrameworkIosSimulatorArm64, enables the configuration cache, and cuts the warm loop to about 80 seconds while leaving CI release artifacts untouched.

Quick Start

Ask the agent to diagnose why your Kotlin Multiplatform iOS build is slow and have it run the audit script against your project root before proposing fixes.

Frequently Asked Questions about kotlin-tooling-native-build-performance

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I speed up slow Kotlin/Native iOS builds?

Start by measuring the exact command you wait for, running it twice so caches are warm. Then enable org.gradle.caching and the configuration cache, replace broad tasks like assembleXCFramework with a single debug link task for local development, and remove transitiveExport from framework binaries.

Why is my Kotlin Multiplatform iOS build slow in CI?

CI builds are slow when the ~/.konan directory is not cached, forcing the Kotlin/Native compiler distribution to download on every run. Add an actions/cache step keyed on your Kotlin version, and consider a remote Gradle build cache to share results across machines.

What Gradle task should I use for local Kotlin iOS development?

Use the narrowest debug task for your integration method: embedAndSignAppleFrameworkForXcode for direct Xcode integration, linkDebugFrameworkIosSimulatorArm64 for a Gradle-only simulator check, or linkPodDebugFrameworkIosSimulatorArm64 for CocoaPods. Reserve XCFramework tasks for CI.

Does transitiveExport slow down Kotlin/Native compilation?

Yes, transitiveExport = true exports the entire transitive dependency closure and disables dead code elimination in many cases. Export only the modules whose API Swift or Objective-C code calls directly, adding back specific modules if Swift compilation fails.

Is kotlin.incremental.native safe to enable?

kotlin.incremental.native is experimental and recompiles only changed parts of a klib, helping warm rebuilds after small edits. Enable it only with explicit agreement, label it experimental in reports, and revert it if builds become broken or inconsistent.

Can I use this without a macOS machine to run builds?

Yes, the audit script and reference guidance support static analysis of build scripts, logs, build scans, and checked-in metrics. The Skill requires stating explicitly when conclusions are static rather than measured.