touchlab / SKIE

SKIE - Swift Kotlin Interface Enhancer
https://skie.touchlab.co/
Apache License 2.0
646 stars 8 forks source link

Xcode fails to compile Skie after upgrading to Kotlin 2.0, using DefaultArgumentInterop feature #88

Open itstheceo opened 4 weeks ago

itstheceo commented 4 weeks ago

Hello, currently upgrading my project to Kotlin 2.0 working through the issues. Android side all good, went to build for iOS and encountering issues from Skie. Details below, let me know if there's any workarounds or if this is a known issue. Cheers!

What is the problem?

Execution failed for task ':shared:linkDebugFrameworkIosSimulatorArm64'.

Undefined symbols for architecture arm64:

  "_kfun:kotlin.reflect.KTypeProjection#copy__Skie_DefaultArguments__299(){}kotlin.reflect.KTypeProjection", referenced from:

      _objc2kotlin_kfun:kotlin.reflect.KTypeProjection#copy__Skie_DefaultArguments__299(){}kotlin.reflect.KTypeProjection in Shared.framework.o

  "_kfun:kotlin.reflect.KTypeProjection#copy__Skie_DefaultArguments__300(kotlin.reflect.KVariance?){}kotlin.reflect.KTypeProjection", referenced from:

      _objc2kotlin_kfun:kotlin.reflect.KTypeProjection#copy__Skie_DefaultArguments__300(kotlin.reflect.KVariance?){}kotlin.reflect.KTypeProjection in Shared.framework.o

  "_kfun:kotlin.reflect.KTypeProjection#copy__Skie_DefaultArguments__301(kotlin.reflect.KType?){}kotlin.reflect.KTypeProjection", referenced from:

      _objc2kotlin_kfun:kotlin.reflect.KTypeProjection#copy__Skie_DefaultArguments__301(kotlin.reflect.KType?){}kotlin.reflect.KTypeProjection in Shared.framework.o

ld: symbol(s) not found for architecture arm64

When does the problem occur?

Building KMP project in Version 15.4 (15F31d) of Xcode, M3 MacBook.

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

Upgrading to Kotlin 2.0

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

0.8.2

What is your SKIE Gradle configuration?

skie {
    features {
        group {
            DefaultArgumentInterop.Enabled(true)
        }
    }
}
FilipDolnik commented 4 weeks ago

Hi!

I was able to reproduce the issue by adding this function to a sample project:

fun foo(): KTypeProjection {
    TODO()
}

(Needed in order to export the problematic type.)

The issue seems to be that Kotlin 2.0 changed how the compiler handles stdlib. This change broke the logic that determines for which code SKIE should generate default arguments without using the defaultArgumentsInExternalLibraries.set(true) option.

In other words, SKIE with Kotlin 2.0 seems to think that stdlib is not an external library.

I will fix the problem. In the meantime, you can workaround the issue by changing your configuration to:

skie {
    features {
        group {
            DefaultArgumentInterop.Enabled(true)
        }
        group("kotlin.") {
            DefaultArgumentInterop.Enabled(false)
        }
    }
}