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

cafonsomota

06/14/2019, 7:14 PM
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

louiscad

06/14/2019, 7:39 PM
What "unable" means in your case?
c

cafonsomota

06/14/2019, 7:41 PM
it seems it’s just not compiling; on the generated folders I have no
out/production
l

louiscad

06/14/2019, 8:00 PM
Is it a library or not?
c

cafonsomota

06/14/2019, 8:13 PM
i’m going to send you a DM - it might be easier 🙂
it’s not a library
h

h0tk3y

06/17/2019, 1:38 PM
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

cafonsomota

06/17/2019, 2:19 PM
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 😕
9 Views