From 0459f29be29720d6ed9e1c4b47a37e8bd1979220 Mon Sep 17 00:00:00 2001 From: davotoula Date: Sun, 14 Jun 2026 17:45:31 +0200 Subject: [PATCH] fix(commons): restore iOS test native-cache workaround dropped in dep bump MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "Updates all dependencies" commit (ece719445) bumped Kotlin to 2.4.0, which removed the `DisableCacheInKotlinVersion.2_3_21` enum value. Rather than bumping the guard, the whole `disableUiKitPrebuiltCache()` workaround was deleted — which reintroduced the iOS test link failure on CI --- commons/build.gradle.kts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/commons/build.gradle.kts b/commons/build.gradle.kts index 8def899ef0..a4e8f233aa 100644 --- a/commons/build.gradle.kts +++ b/commons/build.gradle.kts @@ -1,5 +1,23 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.plugin.mpp.DisableCacheInKotlinVersion +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCacheApi +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget +import org.jetbrains.kotlin.gradle.plugin.mpp.TestExecutable + +// Disables the Kotlin/Native compiler cache for an iOS test binary so the +// Compose ui-uikit klib recompiles fresh instead of linking the broken prebuilt +// cache (see the call site in the `kotlin {}` block). The version guard makes +// Kotlin re-surface this workaround once we move past 2.4.0, so it can be +// dropped when a newer Compose/Kotlin pairing fixes the cache. Wrapped in a +// helper because @OptIn only applies to declarations, not bare statements. +@OptIn(KotlinNativeCacheApi::class) +fun TestExecutable.disableUiKitPrebuiltCache() = + disableNativeCache( + DisableCacheInKotlinVersion.`2_4_0`, + "Compose ui-uikit prebuilt cache references UIViewLayoutRegion (iOS 17+); " + + "linking the iOS test binary fails under Xcode 16.4.", + ) plugins { alias(libs.plugins.kotlinMultiplatform) @@ -50,6 +68,22 @@ kotlin { iosArm64() iosSimulatorArm64() + // Compose Multiplatform 1.11.x ships an `org.jetbrains.compose.ui:ui-uikit` + // prebuilt Kotlin/Native cache whose CMPLayoutRegion object hard-references + // the UIKit class `UIViewLayoutRegion` (introduced in iOS 17). Linking the + // iOS *test* executable against that cache under Xcode 16.4 fails with + // ld: Undefined symbols: _OBJC_CLASS_$_UIViewLayoutRegion + // because the cached object was built for a newer simulator SDK (18.5) than + // the test binary is being linked for (14.0). Disabling the native cache for + // the iOS test binaries makes ui-uikit recompile against the active SDK, + // where the symbol resolves. See disableUiKitPrebuiltCache() above and + // https://kotl.in/disable-native-cache + targets.withType().configureEach { + binaries.withType().configureEach { + disableUiKitPrebuiltCache() + } + } + sourceSets { commonMain { dependencies {