tezvyn:

Kotlin 2.4.0 ships Swift package support and Java 26

AI-drafted, machine-checkedSource: Kotlin Blogintermediate
Kotlin 2.4.0 ships Swift package support and Java 26

Kotlin 2.4.0 adds Swift package dependencies for Native, Java 26 for JVM, and WebAssembly Component Model. Multiplatform teams can consume Swift libraries directly and target newer Java. Upgrade via IntelliJ IDEA, Android Studio, or Gradle.

WHY IT MATTERS: Kotlin 2.4.0 removes several friction points for teams shipping multiplatform code. Swift package support in Kotlin/Native means you can pull Apple ecosystem dependencies directly instead of maintaining bridging wrappers or CocoaPods workarounds. Java 26 support on the JVM target lets server-side and Android projects adopt newer JDKs without waiting for a compiler update. For WebAssembly builds, incremental compilation is now on by default and the Component Model is supported, which tightens the feedback loop for Wasm targets. Gradle 9.5.0 compatibility and automatic Java/JVM target alignment in Maven reduce build configuration toil. These are not experimental flags; they are defaults or stable features you can use in production today.

WHAT CHANGED: The language stabilizes context parameters and explicit backing fields, which cleans up APIs that need to pass implicit contexts or expose property internals safely. The standard library graduates the UUID API to stable and adds sorted-order checks. On Kotlin/JVM, annotations in metadata are enabled by default and Java 26 is fully supported. Kotlin/Native now imports Swift packages as dependencies, exports Swift more reliably, and switches to the CMS garbage collector by default. Kotlin/Wasm enables incremental compilation by default and supports the WebAssembly Component Model. Kotlin/JS gains value class export and ES2015 features during JS code inlining. The compiler also fixes inconsistent inline function behavior during klib compilation, which should reduce mysterious build cache misses.

WHAT TO WATCH: If you maintain a Kotlin Multiplatform library, test the Swift package integration on Apple targets before your next release. Android and backend teams should verify Java 26 compatibility in CI and check that metadata annotations do not bloat artifact sizes. Wasm projects should validate bundle changes after incremental compilation is enabled. Gradle users on older wrappers should plan a toolchain bump to 9.5.0 to stay on the supported path. Review the full compatibility guide before upgrading production builds.

Source: Kotlin Blog

Read the original → Kotlin Blog

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.