Thread
#multiplatform
    v

    Vivek Modi

    4 months ago
    Hey guys I am getting this error when trying to build the project.
    Could not determine the dependencies of task ':linkPodReleaseFrameworkIosX64'.
    Could not resolve all task dependencies for configuration ':iosX64CompileKlibraries'.
    Could not resolve org.jetbrains.kotlinx
    :kotlinx-coroutines-android:1.4.1. Required by: project : > io.insert-koin:koin-android:3.2.0 > androidx.activity:activity-ktx:1.4.0 > androidx.lifecycle:lifecycle-runtime-ktx:2.3.1 project : > io.insert-koin:koin-android:3.2.0 > androidx.activity:activity-ktx:1.4.0 > androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1 > No matching variant of org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1 was found. The consumer was configured to find a usage of 'kotlin-api' of a library, preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native', attribute 'org.jetbrains.kotlin.native.target' with value 'ios_x64' but: - Variant 'apiElements' capability org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1 declares an API of a library: - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' - Other compatible attributes: - Doesn't say anything about its target Java environment (preferred optimized for non-jvm) - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_x64') - Variant 'runtimeElements' capability org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1 declares a runtime of a library: - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' - Other compatible attributes: - Doesn't say anything about its target Java environment (preferred optimized for non-jvm) - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_x64')
    plugins {
        kotlin("multiplatform") version "1.6.21"
        kotlin("native.cocoapods") version "1.6.21"
        id("com.android.library")
        id("maven-publish")
    }
    
    val libraryVersion = "0.0.1"
    var libraryGroup = "com.vivek"
    var libraryArtifactId = "kmm-module"
    
    repositories {
        google()
        mavenCentral()
    }
    
    kotlin {
        android {
            publishLibraryVariants("release", "debug")
        }
        cocoapods {
            version = libraryVersion
            name = "VivekMyCocoaPod"
            framework {
                baseName = "MyFramework"
                isStatic = false
            }
        }
        iosX64()
        iosArm64()
        iosSimulatorArm64()
        sourceSets {
            val commonMain by getting{
                dependencies {
                    implementation("io.insert-koin:koin-core:3.2.0")
                    implementation("io.insert-koin:koin-android:3.2.0")
                }
            }
            val androidMain 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)
            }
        }
    }
    
    android {
        compileSdk = 21
        sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
        defaultConfig {
            minSdk = 21
            targetSdk = 31
        }
        @Suppress("UnstableApiUsage") compileOptions {
            sourceCompatibility = JavaVersion.VERSION_1_8
            targetCompatibility = JavaVersion.VERSION_1_8
        }
    }
    
    publishing {
        publications {
            group = libraryGroup
            publications.withType<MavenPublication> {
                groupId = libraryGroup
                artifactId = libraryArtifactId
                version = libraryVersion
            }
    
            repositories {
                maven {
                    url = uri("<https://maven.pkg.github.com/vivek-modi/kotlinmultiplatfromproject>")
                    credentials {
                        username = (System.getenv("GITHUB_USER") ?: project.properties["GITHUB_USER"]).toString()
                        password = (System.getenv("GITHUB_PERSONAL_ACCESS_TOKEN") ?: project.properties["GITHUB_PERSONAL_ACCESS_TOKEN"]).toString()
                    }
                }
            }
            publications.withType<MavenPublication> {
                println(artifactId)
                artifactId = if (name == libraryArtifactId) {
                    artifactId.toLowerCase()
                } else {
                    "$artifactId-$name".toLowerCase()
                }
            }
        }
    }
    e

    ephemient

    4 months ago
    what makes you think you can use koin-android in commonMain dependencies?
    v

    Vivek Modi

    4 months ago
    ohh My bad