After upgrading from 1.9.23 to 2.0.0-RC1, I get th...
# k2-adopters
l
After upgrading from 1.9.23 to 2.0.0-RC1, I get the following error.
Copy code
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':shared:linkPodDebugFrameworkIosArm64'.
Caused by: java.lang.IllegalStateException: Following dependencies exported in the podDebugFramework binary are not specified as API-dependencies of a corresponding source set:

Files: [/Users/cvb941/.gradle/caches/modules-2/files-2.1/com.benasher44/uuid-iosarm64/0.8.4/34b8d38c65dd651a3680572ca7ac60aa4a2ed493/uuid.klib]
Files: [/Users/cvb941/.gradle/caches/modules-2/files-2.1/dev.icerock.moko/resources-iosarm64/0.24.0-beta-1/c4c45169689fd3a348b9dd322be3c24ae3b9a1f4/resources.klib]
Files: [/Users/cvb941/.gradle/caches/modules-2/files-2.1/dev.icerock.moko/graphics-iosarm64/0.9.0/2484b8f1d0c25aa966e2ebd68bf538047cc1bab9/graphics.klib]
Files: [/Users/cvb941/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core-iosarm64/1.8.0/cea8e525a09fbb5f179bc4237c335170a879c08c/kotlinx-coroutines-core.klib]
Files: [/Users/cvb941/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-datetime-iosarm64/0.5.0/59fd4e92ee56cde95dc20ec968782960f4efb98/kotlinx-datetime.klib]
Files: [/Users/cvb941/.gradle/caches/modules-2/files-2.1/io.arrow-kt/arrow-core-iosarm64/1.1.5/61cfefcae9825594f269deb4f831ac8338829d3e/arrow-core.klib]
Files: [/Users/cvb941/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-serialization-json-iosarm64/1.6.2/404a109ef646ed6fe12b5ea4bfe2d9bf97be8478/kotlinx-serialization-json.klib]
Files: [/Users/cvb941/.gradle/caches/modules-2/files-2.1/com.benasher44/uuid-iosarm64/0.8.4/34b8d38c65dd651a3680572ca7ac60aa4a2ed493/uuid.klib]
Files: [/Users/cvb941/.gradle/caches/modules-2/files-2.1/dev.icerock.moko/resources-iosarm64/0.24.0-beta-1/c4c45169689fd3a348b9dd322be3c24ae3b9a1f4/resources.klib]
Files: [/Users/cvb941/.gradle/caches/modules-2/files-2.1/dev.icerock.moko/graphics-iosarm64/0.9.0/2484b8f1d0c25aa966e2ebd68bf538047cc1bab9/graphics.klib]
Files: [/Users/cvb941/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core-iosarm64/1.8.0/cea8e525a09fbb5f179bc4237c335170a879c08c/kotlinx-coroutines-core.klib]
Files: [/Users/cvb941/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-datetime-iosarm64/0.5.0/59fd4e92ee56cde95dc20ec968782960f4efb98/kotlinx-datetime.klib]
Files: [/Users/cvb941/.gradle/caches/modules-2/files-2.1/io.arrow-kt/arrow-core-iosarm64/1.1.5/61cfefcae9825594f269deb4f831ac8338829d3e/arrow-core.klib]
Files: [/Users/cvb941/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-serialization-json-iosarm64/1.6.2/404a109ef646ed6fe12b5ea4bfe2d9bf97be8478/kotlinx-serialization-json.klib]

Please add them in the API-dependencies and rerun the build.
All of the mentioned dependencies are defined as
api
in commonMain and the project builds on 1.9.23. Copying the dependency to iosMain does not help either.
t
cc @Timofey Solonin
f
Hi! I noticed the same issue while adding support for SKIE for Kotlin 2.0.0. It’s an issue with the order of the dependency and export declaration, here is a reproducer:
Copy code
plugins {
    kotlin("multiplatform") version "2.0.0-Beta5"
}

group = "co.touchlab"
version = "1.0-SNAPSHOT"

repositories {
    mavenLocal()
    mavenCentral()
}

kotlin {
    ios()
    iosSimulatorArm64()
    iosX64()

//    Uncomment and it will work
//    val iosMain by sourceSets.getting {
//        dependencies {
//            api("co.touchlab:kermit:2.0.0")
//        }
//    }

    applyDefaultHierarchyTemplate()

    targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
        binaries {
            framework {
                isStatic = true
                baseName = "SKIE-test"
                freeCompilerArgs = freeCompilerArgs + listOf("-Xbinary=bundleId=Kotlin")
                export("co.touchlab:kermit:2.0.0")
            }
        }
    }
    
//    Uncomment and it will not work
//    val iosMain by sourceSets.getting {
//        dependencies {
//            api("co.touchlab:kermit:2.0.0")
//        }
//    }
}
The crash itself originates in
KotlinNativeLink
object in the validatedExportedLibraries function. The function compares exported libraries with those that are declared as api dependencies. The issue is that the list of API dependencies is computed in the object constructor which happens when you declare the binaries.framework. Because the exported library is not declared yet (the dependencies block is after the framework declaration block), the property
apiFiles
does not contain it. This was the case for a very long time. What has changed in the 2.0.0 is that the KotlinNativeLink is now instantiated eagerly when you declare the binaries.framework. Or more precisely the
Framework
object itself is now instantiated eagerly.
🙌 1
A secondary effect of this issue is also that Gradle plugins cannot add dependencies that they want to export (which is the actual issue I run into with SKIE).
t
Hi folks. Is my understanding correct that you use
freeCompilerArgs
in the
framework
block? Could you please see if using the following instead of the
freeCompilerArgs
helps:
Copy code
linkTaskProvider.configure {
    toolOptions {
        freeCompilerArgs.add("-Xbinary=bundleId=Kotlin")
    }
}
If this doesn't help, could you please provide a reproduction?
f
Yeah, replacing the
freeCompilerArgs = freeCompilerArgs + listOf("-Xbinary=bundleId=Kotlin")
fixes the issue. Touching the
freeCompilerArgs
is what is causing the
KotlinNativeLink
to get created in my case at least.
t
Here is the bug
👍 2
f
To clarify the original message. As it turned out I tested the difference between 1.9.23 and 2.0.0 with a slightly different Gradle configs (missing the key freeCompilerArgs line 😄) so that explains why I haven’t seen the KotlinNativeLink being created eagerly. The issue indeed seems to be that the original
apiFiles
FileCollection was “live” and now it’s not.