Hey Everyone, I have an existing kmp library let's...
# multiplatform
a
Hey Everyone, I have an existing kmp library let's say a-SDK that is distributed for ios/android/js; at the same time I'm trying to create another library b-SDK that will depend on a-SDK and serve same targets(currently built and used locally with
publishKotlinMultiplatformPublicationToCustomLocalRepository
). The issue is that when I build b-SDK, I'm getting:
Copy code
> Could not resolve io.ktor:ktor-client-darwin:2.3.8.
   Required by:
     project :library > a-sdk:sdk:0.2-kmp > a-sdk:common-network:0.2-kmp
     project :library > a-sdk:sdk:0.2-kmp > a-sdk:plugin-universal:0.2-kmp
   > No matching variant of io.ktor:ktor-client-darwin:2.3.8 was found. The consumer was configured to find a component for use during runtime, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.0.2', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but:
     - Variant 'iosArm64ApiElements-published' capability io.ktor:ktor-client-darwin:2.3.8:
       - Incompatible because this component declares a component for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed a component for use during runtime, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'
       - Other compatible attributes:
         - Doesn't say anything about com.android.build.api.attributes.AgpVersionAttr (required '8.0.2')
         - Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'release')
         - Doesn't say anything about its target Java environment (preferred optimized for Android)
...
Just to clarify the configuration for ktor in a-SDK is in separate targets:
Copy code
sourceSets {
    getByName("commonMain") {
      dependencies {
        implementation(projects.common.utils)

        implementation(libs.ktor.core)
        implementation(libs.coroutines.core)
        implementation(libs.ktor.logging)
      }
    }

    getByName("androidMain") {
      dependencies {
        implementation(projects.common.platform)
        implementation(libs.ktor.okhttp)

        implementation(libs.coroutines.android)
      }
    }

    getByName("iosMain") {
      dependencies {
        implementation(libs.ktor.darwin)
      }
    }
  }
Has anyone dealt with similar issues before?
🧵 1
p
Can you show the publishing Gradle file
a
publishing.kts
p
I don't see any wrong doing in the script. I suspect you might be missing to specify
publishLibraryVariants(...)
Copy code
kotlin {
    // ANDROID
    androidTarget {
        publishLibraryVariants("release", "debug")
...
    }
in the androidTarget DSL
Although reading your logs again I think you place
ktor-client-darwin
in the wrong sourceset. It should be only in the iOSMain dependencies
a
One thing I've noticed, is if we drop this part in a-SDK the build issues disappears:
Copy code
getByName("iosMain") {
    dependencies {
        implementation(libs.ktor.darwin)
    }
}
But this doesn't make sense, why iOS target, can't find it, but stops throwing errors without this module. Another workaround I thought of is to publish artefacts for all targets ios/android/js for a-SDK and reimport them in android/ios/js source sets of b-SDK as separate dependencies, but this approach seem quite cumbersome. @Pablichjenkov do you know if it's a common practice?
t
please open a Kotlin issue with repro
p
The regular inter-project dependency should work. If you could show the project or rather, a reproducible project, would help better see what the issue is.