Usage within multiplatform project fails: duplicate library name
Akazm opened this issue · 3 comments
I've been working on adding reaktive to a Kotlin multiplatform project. I've therefore followed the provided documentation file within the project's doc folder, which unfortunately did not work. I've therefore tried to apply suggestions provided my IntelliJ, leading to another issue complaining about a duplicate library name (duplicate library name: com.badoo.reaktive:reaktive
).
This seems to make sense at first glance since I'm using platform-specific implementations for iOS (while deliberately ignoring Android for now). But whenever I erase the dependencies providing platform-specific implementations for iOS, reaktive cannot be exported using the export
statement, since reaktive is not part of the platform-specific dependencies
.
Here's my build.gradle.kts:
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
plugins {
kotlin("multiplatform") version "1.6.20"
id("com.android.library")
}
group = "de.itesign"
version = "1.0-SNAPSHOT"
repositories {
google()
mavenCentral()
}
val reaktiveVersion = "1.2.2"
val reaktiveIos64Version = "1.2.0"
kotlin {
android()
val xcf = XCFramework("SomeCommon")
iosArm64 {
binaries {
framework {
baseName = "SomeCommon"
xcf.add(this)
export("com.badoo.reaktive:reaktive-ios64:$reaktiveIos64Version")
}
}
}
iosSimulatorArm64() {
binaries {
framework {
baseName = "SomeCommon"
xcf.add(this)
export("com.badoo.reaktive:reaktive-iossimulatorarm64:$reaktiveVersion")
}
}
}
iosX64 {
binaries {
framework {
baseName = "SomeCommon"
xcf.add(this)
export("com.badoo.reaktive:reaktive-iossim:$reaktiveIos64Version")
}
}
}
sourceSets {
val commonMain by getting {
dependencies {
api("com.badoo.reaktive:reaktive:$reaktiveVersion")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val androidMain by getting
val androidTest by getting {
dependencies {
implementation("junit:junit:4.13")
}
}
val iosArm64Main by getting {
dependencies {
api("com.badoo.reaktive:reaktive-ios64:$reaktiveIos64Version")
}
}
val iosX64Main by getting {
dependencies {
api("com.badoo.reaktive:reaktive-iossim:$reaktiveIos64Version")
}
}
val iosSimulatorArm64Main by getting {
dependencies {
api("com.badoo.reaktive:reaktive-iossimulatorarm64:$reaktiveVersion")
}
}
val iosMain by creating {
dependsOn(commonMain)
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
}
val iosArm64Test by getting
val iosX64Test by getting
val iosSimulatorArm64Test by getting
val iosTest by creating {
dependsOn(commonTest)
iosX64Test.dependsOn(this)
iosArm64Test.dependsOn(this)
iosSimulatorArm64Test.dependsOn(this)
}
}
}
android {
compileSdkVersion(29)
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdkVersion(24)
targetSdkVersion(29)
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
Can you guys provide any help on what I'm doing wrong here? Is the documentation outdated?
You definitely don't need to define platform specific dependencies like com.badoo.reaktive:reaktive-iossimulatorarm64:$reaktiveVersion
. All you need to do is to specify the dependency in the commonMain
source set, and also export it to the framework.
The following should work:
kotlin {
android()
iosArm64 {
binaries {
framework {
baseName = "SomeCommon"
export("com.badoo.reaktive:reaktive:$reaktiveVersion")
}
}
}
iosSimulatorArm64 {
binaries {
framework {
baseName = "SomeCommon"
export("com.badoo.reaktive:reaktive:$reaktiveVersion")
}
}
}
iosX64 {
binaries {
framework {
baseName = "SomeCommon"
export("com.badoo.reaktive:reaktive:$reaktiveVersion")
}
}
}
sourceSets {
val commonMain by getting {
dependencies {
api("com.badoo.reaktive:reaktive:$reaktiveVersion")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val androidMain by getting
val androidTest by getting {
dependencies {
implementation("junit:junit:4.13")
}
}
val iosMain by creating { dependsOn(commonMain) }
val iosArm64Main by getting { dependsOn(iosMain) }
val iosX64Main by getting { dependsOn(iosMain) }
val iosSimulatorArm64Main by getting { dependsOn(iosMain) }
val iosTest by creating { dependsOn(commonTest) }
val iosArm64Test by getting { dependsOn(iosTest) }
val iosX64Test by getting { dependsOn(iosTest) }
val iosSimulatorArm64Test by getting { dependsOn(iosTest) }
}
}
Ah, I see, thanks for responding so quickly!
The description in the documentation is different from what you're describing here, though.
Let's keep this issue open until I update the Readme.