Hey Guys. I was using Kotlin 1.3.61, with coroutin...
# kotlin-native
p
Hey Guys. I was using Kotlin 1.3.61, with coroutines 1.3.2-native-mt-1 and serialization 0.14.0 I just updated to Kotlin 1.3.71, coroutines 1.3.5-native-mt and serialization 0.20.0 and getting this error when I build for iOS framework Please help
Copy code
e: Cannot access class 'kotlin.Pair'. Check your module classpath for missing or conflicting dependencies
e: Cannot access class 'kotlinx.coroutines.CoroutineExceptionHandler'. Check your module classpath for missing or conflicting dependencies
e: Cannot access class 'kotlin.collections.HashMap'. Check your module classpath for missing or conflicting dependencies
o
I just did this recently without any major issue, mind to share your build script?
p
Sure. I am using an umbrella framework to make framework for ios. Below is the build script for umbrella framework
Copy code
import org.jetbrains.kotlin.backend.common.push
import org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType

plugins {
    id("kotlin-multiplatform")
}

val targetList: MutableList<KotlinNativeTarget> = mutableListOf()
populateIOSTargetList()

val frameworkName = "KNUmbrellaLib"

kotlin {
    val nativeBuildTypes = getNativeBuildTypes()
    targets {
        for (target in targetList) {
            target.apply {
                binaries {
                    framework(frameworkName, nativeBuildTypes) {
//                        embedBitcode("bitcode")
                        export(project(":phonepe-kn-kernel"))
                        export(project(":phonepe-kn-os"))
                        export(project(":analytics"))
                    }
                }
            }
        }
    }

    sourceSets {
        commonMain {
            dependencies {
                api(project(":analytics"))
                implementation("org.jetbrains.kotlin:kotlin-stdlib-common:${rootProject.extra["kotlin"]}")
            }
        }
    }
}

tasks.register<Delete>("cleanFrameworksFolder") {
    val frameworkDir = File(buildDir, "../products/xcode-frameworks")
    val binDir = File(buildDir, "bin")
    delete(frameworkDir, binDir)
}

tasks.create("fat", FatFrameworkTask::class) {
    group = "Universal framework"
    description = "Builds a universal (fat) framework"
    baseName = frameworkName

    val mode = getBuildConfiguration()

    from(frameworks = targetList.map { it.binaries.getFramework(frameworkName, mode) })
    destinationDir = buildDir.resolve("../products/xcode-frameworks")
}

fun populateIOSTargetList() {
    val presetName: String = getPresetName()

    when (presetName) {
        "ios32" -> targetList.push(project.kotlin.iosArm32("ios32"))
        "ios64" -> targetList.push(project.kotlin.iosArm64("ios64"))
        "iosSim" -> targetList.push(project.kotlin.iosX64("iosSim"))
        "fat" -> targetList.addAll(listOf(project.kotlin.iosX64("iosSim"), project.kotlin.iosArm32("ios32"), project.kotlin.iosArm64("ios64")))
        else -> targetList.push(project.kotlin.iosX64("iosSim"))
    }
}

fun getPresetName(): String {
    return if (project.hasProperty("type")) project.properties["type"] as String else "iosSim"
}

fun getNativeBuildTypes(): List<NativeBuildType> {
    return when (getBuildConfiguration()) {
        "DEBUG" -> listOf(NativeBuildType.DEBUG)
        "RELEASE" -> listOf(NativeBuildType.RELEASE)
        else -> listOf(NativeBuildType.DEBUG, NativeBuildType.RELEASE)
    }
}

fun getBuildType(): String {
    return if (project.hasProperty("configuration")) project.properties["configuration"] as String else "DEBUG"
}

fun getBuildConfiguration(): String {
    val buildType: String = getBuildType()
    if (buildType.contains("Debug", ignoreCase = true)) {
        return "DEBUG"
    } else if (buildType.contains("Release", ignoreCase = true)) {
        return "RELEASE"
    } else {
        return "DEBUG"
    }
}

fun getBuildEnvironment(): String {
    return getBuildType().toUpperCase()
            .replace("DEBUG-", "")
            .replace("RELEASE-", "")
            .replace("-", "_")
}

tasks.getByName("build").finalizedBy(tasks.getByName("fat"))
tasks.getByName("assemble").dependsOn(tasks.getByName("cleanFrameworksFolder"))
This is the build script for one of the frameworks
Copy code
plugins {
    id("kotlin-multiplatform")
    id("kotlinx-serialization")
}

repositories {
    maven(url = "<https://kotlin.bintray.com/kotlinx>")
}

kotlin {
    val ios32 = iosArm32("ios32")
    val ios64 = iosArm64("ios64")
    val iosSim = iosX64("iosSim")

    targets {
        targetFromPreset(presets.getByName("jvm"), "android")

        ios32.apply {  }
        ios64.apply {  }
        iosSim.apply {  }
    }
    sourceSets {
        commonMain {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-stdlib-common:1.3.61")
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.2-native-mt-1")
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:0.14.0")
                implementation("org.jetbrains.kotlin:kotlin-reflect:1.3.61")
                implementation("org.jetbrains.kotlinx:atomicfu-common:0.14.1")
                api(project(":phonepe-kn-os"))
            }
        }

        commonTest {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-test-common:1.3.61")
                implementation("org.jetbrains.kotlin:kotlin-test-annotations-common:1.3.61")
                implementation("org.mockito:mockito-inline:3.0.0")
                implementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0")
                implementation("org.jetbrains.kotlinx:atomicfu:0.14.1")
            }
        }

        maybeCreate("androidMain")
        getByName("androidMain") {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.61")
                implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.61")
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2-native-mt-1")
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.14.0")
                implementation("com.google.code.gson:gson:2.8.5")
            }
        }


        maybeCreate("androidTest")
        getByName("androidTest") {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-test:1.3.61")
                implementation("org.jetbrains.kotlin:kotlin-test-junit:1.3.61")
            }
        }

        val ios32Main by getting {
            dependencies {
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.2-native-mt-1")
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:0.14.0")
                implementation("org.jetbrains.kotlinx:atomicfu-native:0.14.1")
            }
        }

        val ios32Test by getting {
            dependencies {

            }
        }

        val ios64Main by getting {
            dependsOn(ios32Main)
        }

        val ios64Test by getting {
            dependsOn(ios32Test)
        }

        val iosSimMain by getting {
            dependsOn(ios32Main)
        }

        val iosSimTest by getting {
            dependsOn(ios32Test)
        }
    }
}
Hey @Omar Mainegra I have created a small reproducible project with two branches. master that does not build and gives an error and working-old-version that builds successful. The only difference between the two branches is the versions of libs. Will it be possible for you to test it once and if possible, help? https://github.com/kerry/kn-multilib
o
Sure, 👀
BTW 1.3.72 is out, you should give it a try, but I don't think your issue is related to it tho
p
yeah. its more related to inter module dependency. if i remove the dependency and just add the code in the same module, it works.