I posted this in <#C3PQML5NU|multiplatform> but de...
# kotlin-native
h
I posted this in #multiplatform but deleted the post since I think this is the more appropriate channel because it’s more of an iOS Kotlin Native issue: Hi all, I’m currently running into an archiving issue with an iOS app using a framework created from Kotlin multiplatform with the FatFrameworkTask. Previous versions worked and the iOS app has live builds with the framework, however, in the latest attempt to create a new Testflight build where I upgraded the following dependencies in the KMP project:
Copy code
const val kotlin_version = "1.3.61" previously "1.3.40"
const val coroutines_version = "1.3.3" previously "1.3.40"
const val ktor_version = "1.2.6" previously  "1.2.2"
const val serialization_version = "0.14.0" previously "0.11.1"
const val mockk_version = "1.9.3"
The framework is created. The app works in debug mode. The issue is strictly archiving. I’m running into this issue:
Copy code
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
Intrinsic has incorrect argument type!
i32 (i8*, i1, i1, i1)* @llvm.objectsize.i32.p0i8
LLVM ERROR: Broken module found, compilation aborted!
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Command Ld failed with a nonzero exit code
Has anyone encountered this issue? I’m quite sure it’s related to the changes in the KMP project because reverting the framework (via cocoapods) to the previous version results in a successful archiving. The minimum target for the app is iOS 10.0 so a 32 bit architecture is supported
s
Hello! What is your Xcode version?
♥️ 2
h
Xcode 10.3
s
Kotlin/Native 1.3.61 requires Xcode 11 (https://github.com/JetBrains/kotlin-native#kotlinnative). Update should help.
h
Ahh. Thanks for the help
s
No problem :)
i
Hi @hooliooo! Actually the compiler checks the Xcode version during the build and it's strange that it didn't it in your case. Could you please tell us how did you update Kotlin version? Did you just update the version of the
kotlin-multiplatform
Gradle plugin or use project properties to update the K/N version only (like
kotlin.native.version=...
). Is it possible to you to share the project with us so we can try to reproduce this issue?
h
Copy code
plugins {
    kotlin("multiplatform") version Libs.kotlin_version
    id("kotlinx-serialization") version Libs.kotlin_version
    maven
    id("org.jetbrains.kotlin.native.cocoapods") version Libs.kotlin_version
    id("maven-publish")
    //id("co.touchlab.kotlinxcodesync") version "0.1.2"
}
val connect_library_version: String by project

group = "com.MyApp.app.module.connect"
version = connect_library_version

kotlin {

    val iosConfig: KotlinNativeTarget.() -> Unit = {
        binaries.getFramework(NativeBuildType.DEBUG).baseName = "MyAppBusinessLogicLib"
        binaries.getFramework(NativeBuildType.RELEASE).baseName = "MyAppBusinessLogicLib"

        compilations["main"].defaultSourceSet {

            dependencies {
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-native:${Libs.coroutines_version}")
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:${Libs.serialization_version}")

                implementation("io.ktor:ktor-client-ios:${Libs.ktor_version}")
                implementation("io.ktor:ktor-client-core-native:${Libs.ktor_version}")
                implementation("io.ktor:ktor-client-json-native:${Libs.ktor_version}")
                implementation("io.ktor:ktor-client-serialization-native:${Libs.ktor_version}")
                implementation("io.ktor:ktor-client-logging-native:${Libs.ktor_version}")
            }
        }
        compilations["test"].defaultSourceSet {
            dependencies {
                implementation("io.ktor:ktor-client-mock-native:${Libs.ktor_version}")
            }
        }
        compilations["main"].extraOpts.addAll(listOf("-module-name", "SC"))
    }

    val iosArm32 = iosArm32("iosArm32", iosConfig)
    val iosArm64 = iosArm64("iosArm64", iosConfig)
    val iosX64 = iosX64("iosX64", iosConfig)

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-stdlib")
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:${Libs.coroutines_version}")
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:${Libs.serialization_version}")

                implementation("io.ktor:ktor-client-core:${Libs.ktor_version}")
                implementation("io.ktor:ktor-client-json:${Libs.ktor_version}")
                implementation("io.ktor:ktor-client-serialization:${Libs.ktor_version}")
                implementation("io.ktor:ktor-client-logging:${Libs.ktor_version}")
            }
        }
        val commonTest by getting {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-test-common")
                implementation("org.jetbrains.kotlin:kotlin-test-annotations-common")
                implementation("io.mockk:mockk-common:${Libs.mockk_version}")
                implementation("io.mockk:mockk:${Libs.mockk_version}")
                implementation("io.ktor:ktor-client-mock:${Libs.ktor_version}")
            }
        }
        jvm().compilations["main"].defaultSourceSet {

            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-stdlib:${Libs.kotlin_version}")
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Libs.coroutines_version}")

                implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:${Libs.serialization_version}")

                implementation("io.ktor:ktor-client-core-jvm:${Libs.ktor_version}")
                implementation("io.ktor:ktor-client-json-jvm:${Libs.ktor_version}")
                implementation("io.ktor:ktor-client-serialization-jvm:${Libs.ktor_version}")
                implementation("io.ktor:ktor-client-logging-jvm:${Libs.ktor_version}")
                implementation("io.ktor:ktor-client-okhttp:${Libs.ktor_version}") {
                    exclude(group = "com.squareup.okhttp3")
                }
                implementation("com.squareup.okhttp3:okhttp:3.12.1")
                implementation("org.slf4j:slf4j-simple:1.7.25")
            }
        }
        jvm().compilations["test"].defaultSourceSet {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-test")
                implementation("org.jetbrains.kotlin:kotlin-test-junit")
                implementation("io.mockk:mockk:${Libs.mockk_version}")
                implementation("io.ktor:ktor-client-mock-jvm:${Libs.ktor_version}")
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${Libs.coroutines_version}")
            }
        }
        //share source + test source code
        listOf(iosArm32, iosArm64, iosX64).forEach {
            sourceSets["${it.targetName}Main"].kotlin.srcDir("src/iosMain/kotlin")
            sourceSets["${it.targetName}Test"].kotlin.srcDir("src/iosTest/kotlin")
        }

        /*val jsMain by getting {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-stdlib-js")
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$coroutines_version")
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$serialization_version")
                implementation("io.ktor:ktor-client-js:$ktor_version")
                implementation("io.ktor:ktor-client-json-js:$ktor_version")
            }
        }
        val jsTest by getting {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-test-js")
                implementation("io.mockk:mockk:$mockk_version")
            }
        }*/

    }
    jvm {
        apply(from = File("dokka.gradle"))
    }

    tasks.create("debugFatFramework", FatFrameworkTask::class) {
        baseName = "MyAppBusinessLogicLib"
        from(
            iosArm32.binaries.getFramework("DEBUG"),
            iosArm64.binaries.getFramework("DEBUG"),
            iosX64.binaries.getFramework("DEBUG")
        )
        destinationDir = File(buildDir, "build")
        group = "Universal framework"
        description = "Builds a universal (fat) debug framework"
    }


    tasks.create("releaseFatFramework", FatFrameworkTask::class) {
        baseName = "MyAppBusinessLogicLib"
        from(
            iosArm32.binaries.getFramework("RELEASE"),
            iosArm64.binaries.getFramework("RELEASE"),
            iosX64.binaries.getFramework("RELEASE")
        )
        destinationDir = File(buildDir, "build")
        group = "Universal framework"
        description = "Builds a universal (fat) release framework"
    }

    tasks.create("iosTest") {
        val device = project.findProperty("iosDevice")?.toString() ?: "iPhone 8"
        dependsOn(iosX64.binaries.getTest("", NativeBuildType.DEBUG).linkTask)
        group = JavaBasePlugin.VERIFICATION_GROUP
        description = "Runs tests for target 'ios' on an iOS simulator"

        doLast {
            val binary = iosX64.binaries.getTest(NativeBuildType.DEBUG).outputFile
            exec {
                commandLine("xcrun", "simctl", "spawn", "--standalone", device, binary.absolutePath)
            }
        }
    }

    cocoapods {
        summary = "MyApp Connect API Wrapper"
        homepage = "<https://www.myapp.com>"
        authors = "mycompany"
        license = "MIT"
    }
}


val someArtifactsGradleAccessToken: String by project

tasks.create("emptyJar", Jar::class) {

}

tasks.create("stubJavadoc", Jar::class) {
    archiveClassifier.set("javadoc")
}

tasks.create("stubDokka", Jar::class) {
    archiveClassifier.set("kdoc")
}

configure<PublishingExtension> {
    repositories {
        maven {
            setUrl("<https://pkgs.dev.azure.com/mycompany/_packaging/Android/maven/v1>")
            credentials {
                username = "SOME_ARTIFACTS"
                password = System.getenv("SOME_ARTIFACTS_ENV_ACCESS_TOKEN") ?: "${someArtifactsGradleAccessToken}"
            }
        }
    }
    publications.withType<MavenPublication>().forEach {

        it.pom.apply {
            withXml {
                val root = asNode()
                root.appendNode("name", "MyApp-connect")
                root.appendNode("description", "MyApp Connect Wrapper API")
                root.appendNode("url", "<https://myapp.com>")

                /*val dependenciesNode = asNode().getAt(QName("dependencies")).firs
                if (dependenciesNode != null) {
                    val dependencyNode = dependenciesNode.appendNode("dependency")
                    dependencyNode.appendNode("groupId", "$group")
                    dependencyNode.appendNode("artifactId", "$project.name")
                    dependencyNode.appendNode("version", "$project.version")
                }*/
            }
            licenses {
                license {
                    name.set("The Apache Software License, Version 2.0")
                    url.set("<http://www.apache.org/licenses/LICENSE-2.0.txt>")
                    distribution.set("repo")
                }
            }
            developers {
                developer {
                    id.set("mycompany")
                    name.set("Some Company")
                    organization.set("mycompany")
                    organizationUrl.set("<http://www.mycompany.com>")
                }
            }
        }


    }
    publications.withType<MavenPublication>().apply {

        val jvm by getting {

        }
        val iosArm32 by getting {

        }
        val iosArm64 by getting {

        }
        val iosX64 by getting {

        }
        val metadata by getting {

        }
        val kotlinMultiplatform by getting {
            //artifact("emptyJar")
        }
    }
}
🙏 1
Hi @ilya.matveev, I updated the kotlin multiplatform gradle plugin. Unfortunately I cannot share the project I just updated my
Libs.kt
file with the new versions
Copy code
object Libs {
    const val kotlin_version = "1.3.61"
    const val coroutines_version = "1.3.3"
    const val ktor_version = "1.3.0"
    const val serialization_version = "0.14.0"
    const val mockk_version = "1.9.3"
}
and my
build.gradle.kts
file looks like this:
@ilya.matveev Btw, if it means anything I have both Xcode 10.3 and Xcode 11 installed. The older one is named Xcode10.3.app while Xcode.app is Xcode 11
s
This actually explains the problem, thank you.