Skip to content

defaultArgumentsInExternalLibraries no longer disables the Kotlin/Native cache on Kotlin ≥ 2.3.20 #207

Description

@caseymorris61

Questions:

What is the problem?

The kotlin.native.cacheKind gradle property was deprecated so now the framework link task fails with undefined symbols for SKIE-generated default-argument bridges belonging to an external library type when defaultArgumentsInExternalLibraries is set to true:

w: :warning: Deprecated Gradle Property 'kotlin.native.cacheKind.iosSimulatorArm64' Used
The `kotlin.native.cacheKind.iosSimulatorArm64` deprecated property is used in your build.
Solutions:
 * It is unsupported, please stop using it.
 * This property is deprecated. If you still need to disable the native cache, then use a new DSL. It was removed in 2.3.20, see https://kotl.in/disable-native-cache for details.

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

> Task :linkDebugFrameworkIosSimulatorArm64 FAILED
w: -memory-model and memoryModel switches are deprecated and will be removed in a future release.
w: freezing switch is deprecated and will be removed in a future release.
e: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors
Please try to disable compiler caches (https://kotl.in/disable-native-cache) and rerun the build.

The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1.
output:
ld: warning: ignoring duplicate libraries: '-ldl', '-lz'
Undefined symbols for architecture arm64:
  "_kfun:com.apollographql.apollo.api.CompiledCondition#copy__Skie_DefaultArguments__54(){}com.apollographql.apollo.api.CompiledCondition", referenced from:
      _objc2kotlin_kfun:com.apollographql.apollo.api.CompiledCondition#copy__Skie_DefaultArguments__54(){}com.apollographql.apollo.api.CompiledCondition in ClientCommon.framework.o

The Obj-C export references SKIE's default-argument bridges for a cached external klib, but the Kotlin bodies of those bridges are not in the linked objects.

When does the problem occur?

Fails during: Task :linkDebugFrameworkIosSimulatorArm64

How do we reproduce the issue?

  1. A KMP project on Kotlin 2.4.20 using SKIE with defaultArgumentsInExternalLibraries enabled.
  2. Depend on an external library that exposes declarations with default arguments — here Apollo's com.apollographql.apollo.api.CompiledCondition, whose copy(...) has default args.
  3. Run the framework link task (linkDebugFrameworkIosSimulatorArm64).

Hypothesized Root Cause

Did some debug with Claude and reached this conclusion:

Root cause: SKIE disables the Kotlin/Native static cache for the defaultArgumentsInExternalLibraries feature by setting the Gradle property
  kotlin.native.cacheKind.<target> (in DisableCachingForDefaultArguments.kt). That property was removed in Kotlin 2.3.20, replaced by the per-binary
  disableNativeCache(...) DSL. On Kotlin ≥ 2.3.20 the assignment still runs but is ignored, so the cache stays enabled, the injected bridges for external
  (cached) klibs are served from cache without SKIE's bodies, and the link fails.

  Secondary symptom: the same code path emits a spurious kotlin.native.cacheKind.<target> deprecation warning (e.g. cacheKind.iosSimulatorArm64).

  Verified on the consumer side: adding a per-binary disableNativeCache(version = …, reason = …) in the framework {} block makes the link succeed, which
  confirms the cause and that the DSL reaches the cached external dependency.

What has changed since the last time SKIE worked in your project?

Upgrading Kotlin to a version ≥ 2.3.20 (specifically for me, I was trying 2.4.20 from #202 , though fails with 2.4.10 as well). The feature worked before upgrading kotlin from 2.1.0 where kotlin.native.cacheKind. still existed.

What versions of SKIE, Kotlin, and Gradle do you use?

What is your SKIE Gradle configuration?

skie {
    build {
        enableSwiftLibraryEvolution.set(true)
    }
    features {
        group {
            EnumInterop.Enabled(true)
            SealedInterop.Enabled(true)
            FlowInterop.Enabled(false)
            DefaultArgumentInterop.Enabled(true)
            defaultArgumentsInExternalLibraries.set(true)
            FunctionInterop.FileScopeConversion.Enabled(false)
            coroutinesInterop.value(false)
        }
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions