I'm trying to create a KMM project that publishes to Cocoapods using KMMBridge. This works fine for a basic project that only returns a strings, but when adding dependencies to make a http requests or parse json, it stops working.
I followed the Get started with Kotlin Multiplatform Mobile and after finishing, I started adding the KMMBridge code to the Gradle script. Just adding the KMMBridge plugin
id("co.touchlab.faktory.kmmbridge") version "0.3.7"
breaks the build with the following error:
Caused by: java.lang.IllegalArgumentException: This fat framework already has a binary for architecture `arm64` (shared for target `ios_arm64`)
Project can be found here: https://github.com/ionel71089/KotlinMultiplatformSandbox
Here is the build.gradle.kts
file for the shared
module:
val ktorVersion = "2.2.4"
version = "0.1"
plugins {
kotlin("multiplatform")
id("com.android.library")
kotlin("plugin.serialization") version "1.8.20"
kotlin("native.cocoapods")
id("co.touchlab.faktory.kmmbridge") version "0.3.4" // breaks build
// `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("test"))
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 {
summary = "KMMBridgeSampleKotlin"
homepage = "https://touchlab.dev"
ios.deploymentTarget = "13"
}
}
android {
namespace = "com.example.kotlinmultiplatformsandbox"
compileSdk = 33
defaultConfig {
minSdk = 24
targetSdk = 33
}
}
/*
addGithubPackagesRepository()
kmmbridge {
mavenPublishArtifacts()
githubReleaseVersions()
spm()
cocoapods("git@github.com:ionel71089/PublicPodspecs.git")
versionPrefix.set("0.8")
}
*/
Note: I've also tried adding the dependencies to a trivial KMMBridge sample project, but that didn't work either (https://github.com/ionel71089/KMMBridgeSampleKotlin).
You're duplicating your framework definitions. See the KMMBridge Troubleshooting doc: