I am trying to use targetHierarchy and androidTarg...
# multiplatform
p
I am trying to use targetHierarchy and androidTarget() in my build.gradle for
shared
module, but keep getting
unresolved reference
. I am on kotlin 1.9.0. The errors I am getting are :
Copy code
e: .../shared/build.gradle.kts:11:5: Unresolved reference: androidTarget
e: .../shared/build.gradle.kts:23:5: Unresolved reference: targetHierarchy
e: .../shared/build.gradle.kts:24:9: Unresolved reference: common
I tried clear project and invalidate caches few times. the file in 🧵 👇
Copy code
plugins {
    kotlin("multiplatform")
    id("com.android.library")
    id("co.touchlab.faktory.kmmbridge") version "0.3.7"
    id("maven-publish")
}

version = "1.0"

kotlin {
    androidTarget()
    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach {
        it.binaries.framework {
            baseName = "shared"
            isStatic = true
        }
    }

    targetHierarchy.default {
        common {
            group("mobile") {
                withIos()
                withAndroidTarget()
            }
        }
    }

    sourceSets {
        val commonMain by getting {
            dependencies {
                //put your multiplatform dependencies here
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
            }
        }
    }
}

android {
    namespace = "retrolabs.retroapp.shared"
    compileSdk = ConfigurationData.compileSdk
    defaultConfig {
        minSdk = ConfigurationData.minSdk
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }
}

kmmbridge {
    frameworkName.set("shared")
    mavenPublishArtifacts()
    githubReleaseVersions()
    spm()
    versionPrefix.set("0.3")
}
a
Is the Kotlin multiplatform plugin version set to 1.9.0 too???
p
How can I check that? When I put version like this: kotlin("multiplatform") version "1.9.0" I have an error that I cannot set the version for this plugin
x
If it doesn't allow you to specify the version, that may mean that it is a Gradle core plugin.

Check out this video to understand that

p
Thanks for the hints guys. For some reason the
kmmBridge
is messing up with the multiplatform kotlin 1.9.0, at least on my machine. Without that plugin everything is back to normal.
👍 1
k
KMMBridge Gradle plugin version issues should be fixed in the latest (
0.5.1
). We reference the KMP Gradle plugin in KMMBridge, but it was an
implementaiton
dependency. Now
compileOnly
. However, if your project is based on KMMBridge
0.3.x
, just be aware that KMMBridge
0.5.x
is fairly different. A lot of the logic around versioning was moved to CI.
398 Views