From 9671fc4d04f6a6c45876cce735d3756df0636042 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 9 Jun 2026 21:44:11 +0000 Subject: [PATCH] fix(commons): disable native cache for iOS test binary to fix ui-uikit link The :commons:linkDebugTestIosSimulatorArm64 CI step fails under Xcode 16.4 with 'Undefined symbols: _OBJC_CLASS_$_UIViewLayoutRegion'. The symbol is referenced by the prebuilt Kotlin/Native cache of Compose Multiplatform's org.jetbrains.compose.ui:ui-uikit (CMPLayoutRegion), which was built against a newer simulator SDK (18.5) than the test binary is linked for (14.0). Disable the native compiler cache for the iOS test binaries so ui-uikit recompiles against the active SDK, where UIViewLayoutRegion resolves. The DisableCacheInKotlinVersion guard re-surfaces the workaround once we move past Kotlin 2.3.21 so it can be removed when the cache is fixed upstream. --- commons/build.gradle.kts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/commons/build.gradle.kts b/commons/build.gradle.kts index 8def899ef0..0cec8f4877 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.3.21, 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_3_21`, + "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.0 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() below and + // https://kotl.in/disable-native-cache + targets.withType().configureEach { + binaries.withType().configureEach { + disableUiKitPrebuiltCache() + } + } + sourceSets { commonMain { dependencies {