hello all, I’m trying to add a Kotlin JS module t...
# multiplatform
c
hello all, I’m trying to add a Kotlin JS module to an existing Android/iOS multiplatform project - but I seem to keep having some errors. I’m not sure if this is the best approach but my current project structure is to have:
- src/androidMain
- src/iOSMain
- src/jsMain
and my app/build.gradle follows the same approach, having all these modules on the dependencies:
Copy code
sourceSets {
        commonMain {
            dependencies {
                implementation kotlin('stdlib-common')
                ...
            }
       }
       androidMain...
       iOSMain...
       jsMain...
at this moment I’ve managed to compile the project both for android and iOS and my js module is capable to access to commonMain (shared code). However, it seems that I’m unable to compile the JavaScript itself 😕. Any idea what I could be doing wrong?
l
What "unable" means in your case?
c
it seems it’s just not compiling; on the generated folders I have no
out/production
l
Is it a library or not?
c
i’m going to send you a DM - it might be easier 🙂
it’s not a library
h
Did you also declare a
js()
target? You need to call
js()
in the
kotlin { ... }
scope for the plugin to setup the JS compilations.
c
yes, I’ve declared
js()
inside
kotlin {}
and I’ve also declared the dependencies for
jsMain
Copy code
jsMain {
            dependencies {
                //implementation kotlin('stdlib-js')
                implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
                implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:${versions.serialization}"

                // HTTP
                implementation "io.ktor:ktor-client-js:${versions.ktor}"
                implementation "io.ktor:ktor-client-json:${versions.ktor}"
                implementation "io.ktor:ktor-client-json-js:${versions.ktor}"
                implementation "io.ktor:ktor-client-serialization-js:${versions.ktor}"

                // Coroutines
                implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:${versions.coroutines}"
            }
        }
but now when I try to run
index.html
it seems it doesn’t find the dependencies 😕