https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
a

Ahmed Mourad

06/02/2021, 9:45 PM
Hey everybody, I have two multiplatform modules
A
and
B
, both of which only contain
commonMain
and
commonTest
source sets and have
jvm
,
js
and
ios
as targets. Also
B
depends on
A
. The problem is I can't reference the classes defined in the
commonMain
of
A
inside the
commonMain
of
B
, so something is probably wrong with my Gradle files...
This's what
build.gradle
of
A
looks like:
Copy code
kotlin {
    jvm()
    js {
        browser()
        nodejs()
    }
    ios()
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(kotlin("stdlib-common"))
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
            }
        }
    }
}
And this's what
build.gradle
of
B
looks like:
Copy code
kotlin {
    jvm()
    js {
        browser()
        nodejs()
    }
    ios()
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(kotlin("stdlib-common"))
                implementation(project(":a"))
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
            }
        }
    }
}
r

rnett

06/02/2021, 9:48 PM
That looks fine to me. Although note that you don't need the
stdlib
dependencies any more, and should use
kotlin("test")
instead of
test-common
and
test-annotations-common
. Does it actually fail to compile, or is the IDE just complaining?
💯 1
a

Ahmed Mourad

06/02/2021, 10:01 PM
I just tried building it, it does seem to be an IDE problem, thanks!
4 Views