Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Targets

Status: 🟢 JVM. 🟡 Android, JavaScript, and Native have compiler backends but are not reachable from a multi-target build yet. ⚪ WebAssembly. See Implementation Status.

A target is a platform you compile for. Declare them in [targets]; every name below is accepted in kebab-case or camelCase (ios-arm64 and iosArm64 are the same target).

Every target

NamePlatformStatus
jvmKotlin/JVM🟢
androidKotlin/JVM for Android🟡
jsKotlin/JS🟡
wasm-jsKotlin/Wasm, browser⚪
wasm-wasiKotlin/Wasm, WASI⚪
ios-arm64iOS device🟡
ios-simulator-arm64iOS simulator, Apple silicon🟡
ios-x64iOS simulator, Intel🟡
macos-arm64macOS, Apple silicon🟡
macos-x64macOS, Intel🟡
linux-x64Linux, x86_64🟡
linux-arm64Linux, ARM64🟡
mingw-x64Windows, x86_64🟡
tvos-arm64tvOS device🟡
tvos-simulator-arm64tvOS simulator🟡
watchos-arm64watchOS device🟡
watchos-simulator-arm64watchOS simulator🟡
android-native-arm64Android NDK, ARM64🟡
android-native-x64Android NDK, x86_64🟡

jvm

[targets.jvm]
java-target = "25"
OptionDefaultDescription
java-target25Bytecode level. "17", "21", "25".

Output: a JAR in build/jvm/<profile>/output/. Source sets: src/main/kotlin for single-target projects, src/jvmMain/kotlin for multiplatform ones.

java-target is independent of the JDK you compile with — build on JDK 25 and emit Java 17 bytecode if that is what you deploy onto.

android

[targets.android]
min-sdk = 24
target-sdk = 36
compile-sdk = 36
java-target = "17"
OptionDefaultDescription
min-sdk24Minimum supported API level.
target-sdk36API level the app is tested against.
compile-sdk36API level compiled against.
java-target25Bytecode level.

min-sdk <= target-sdk is validated. Kargo locates the Android SDK via [toolchain], ANDROID_SDK in .kargo.env, ANDROID_HOME, or ANDROID_SDK_ROOT, and installs the required platform if missing.

android.* resolves against the compile-sdk platform. If it is not installed, Kargo says so and names the kargo toolchain install --android that fixes it.

.aar dependencies work like jars. AndroidX is published only to Google's Maven, so declare it:

[repositories]
google = "https://maven.google.com"

Status: 🟡 Compiles Kotlin against the Android SDK and .aar dependencies. Resource compilation, manifest merging, and APK or AAB packaging are planned.

javascript

[targets.js]
module-kind = "es"
OptionValuesDefaultDescription
module-kindes, commonjsesModule format emitted.

Use es for bundlers and modern browsers, commonjs for older Node tooling. Output: .js plus .d.ts declarations. Node.js is needed to run JS tests.

native

The Kotlin/Native family: ios-*, macos-*, linux-*, mingw-x64, tvos-*, watchos-*, android-native-*.

[targets]
ios-arm64 = {}
ios-simulator-arm64 = {}
macos-arm64 = {}
linux-x64 = {}

No per-target options besides cinterop. Output is a .framework for Apple targets, an executable or shared library elsewhere.

Host requirements. Kotlin/Native does not cross-compile between operating systems:

Target familyRequired host
ios-*, macos-*, tvos-*, watchos-*macOS with Xcode
linux-*Linux
mingw-x64Windows
android-native-*Linux or macOS, with the NDK

This is a Kotlin/Native constraint, not a Kargo one. Plan CI matrices around it — see Continuous Integration.

cinterop

Status: ⚪ Planned.

[target.ios-arm64.cinterop.mylib]
def-file = "src/nativeInterop/cinterop/mylib.def"
headers = ["include/mylib.h"]
compiler-opts = ["-Iinclude"]
linker-opts = ["-L/usr/local/lib", "-lmylib"]
KeyTypeDescription
def-filestringThe .def describing the library. Required.
headerslistHeaders to process.
compiler-optslistFlags for the C compiler.
linker-optslistFlags for the linker.

webassembly

Status: ⚪ Planned.

[targets]
wasm-js = {}
wasm-wasi = {}

wasm-js targets browsers with JavaScript interop; wasm-wasi targets WASI runtimes. Output is a .wasm module plus glue code for wasm-js.

Choosing a target name

For iOS, declare both ios-arm64 (device) and ios-simulator-arm64 (simulator) — you need both to develop and ship, and shared code goes in src/iosMain via the source-set hierarchy.

Add ios-x64 only if you still support Intel Macs for simulator builds.

Source-set mapping

TargetTarget-specific source setShared with
jvmsrc/jvmMain/kotlincommonMain
androidsrc/androidMain/kotlincommonMain
jssrc/jsMain/kotlinjsAndWasmMain, commonMain
ios-arm64src/iosArm64Main/kotliniosMain, appleMain, nativeMain, commonMain
linux-x64src/linuxX64Main/kotlinnativeMain, commonMain

Full rules in Source Sets.

Next