HomeiOS Developmentios - KMM construct fails after including KMMBridge plugin, if dependencies exist

ios – KMM construct fails after including KMMBridge plugin, if dependencies exist


I am making an attempt to create a KMM undertaking that publishes to Cocoapods utilizing KMMBridge. This works high quality for a fundamental undertaking that solely returns a strings, however when including dependencies to make a http requests or parse json, it stops working.

I adopted the Get began with Kotlin Multiplatform Cellular and after ending, I began including the KMMBridge code to the Gradle script. Simply including the KMMBridge plugin

id("co.touchlab.faktory.kmmbridge") model "0.3.7"

breaks the construct with the next error:

Attributable to: java.lang.IllegalArgumentException: This fats framework already has a binary for structure `arm64` (shared for goal `ios_arm64`)

Mission may be discovered right here: https://github.com/ionel71089/KotlinMultiplatformSandbox

Right here is the construct.gradle.kts file for the shared module:

val ktorVersion = "2.2.4"

model = "0.1"

plugins {
    kotlin("multiplatform")
    id("com.android.library")
    kotlin("plugin.serialization") model "1.8.20"
    kotlin("native.cocoapods")

    id("co.touchlab.faktory.kmmbridge") model "0.3.4" // breaks construct
//    `maven-publish`
}

kotlin {
    android {
        compilations.all {
            kotlinOptions {
                jvmTarget = "1.8"
            }
        }
    }
    
    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach {
        it.binaries.framework {
            baseName = "shared"
        }
    }

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")
                implementation("io.ktor:ktor-client-core:$ktorVersion")
                implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion")
                implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")
            }
        }

        val commonTest by getting {
            dependencies {
                implementation(kotlin("check"))
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
            }
        }

        val androidMain by getting {
            dependencies {
                implementation("io.ktor:ktor-client-android:$ktorVersion")
            }
        }
        val androidUnitTest by getting

        val iosX64Main by getting
        val iosArm64Main by getting
        val iosSimulatorArm64Main by getting

        val iosMain by creating {
            dependsOn(commonMain)
            iosX64Main.dependsOn(this)
            iosArm64Main.dependsOn(this)
            iosSimulatorArm64Main.dependsOn(this)
            dependencies {
                implementation("io.ktor:ktor-client-darwin:$ktorVersion")
            }
        }

        val iosX64Test by getting
        val iosArm64Test by getting
        val iosSimulatorArm64Test by getting

        val iosTest by creating {
            dependsOn(commonTest)
            iosX64Test.dependsOn(this)
            iosArm64Test.dependsOn(this)
            iosSimulatorArm64Test.dependsOn(this)
        }
    }

    cocoapods {
        abstract = "KMMBridgeSampleKotlin"
        homepage = "https://touchlab.dev"
        ios.deploymentTarget = "13"
    }
}

android {
    namespace = "com.instance.kotlinmultiplatformsandbox"
    compileSdk = 33
    defaultConfig {
        minSdk = 24
        targetSdk = 33
    }
}

/*
addGithubPackagesRepository()
kmmbridge {
    mavenPublishArtifacts()
    githubReleaseVersions()
    spm()
    cocoapods("git@github.com:ionel71089/PublicPodspecs.git")
    versionPrefix.set("0.8")
}
 */

Word: I’ve additionally tried including the dependencies to a trivial KMMBridge pattern undertaking, however that did not work both (https://github.com/ionel71089/KMMBridgeSampleKotlin).

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments