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

Cicero

11/30/2020, 1:50 PM
A library right I was wondering about this. In the past when my project was going to happen in React Native I wrote a node library for connectivity and models Is it similar to a node library? Could I also export my network from common as a library? Also brings me to another question, would I to be able to work in my common without having all this android stuff around? I would like to, for example, run my common independently.
s

Sam

11/30/2020, 2:07 PM
Common is like an abstract class. It needs a target platform to run. If you want a lightweight platform without needing anything special to run tests, try adding a jvm platform. In my project I have jvm, Android and iOS platforms. The expect/actual classes in the jvm target are stubbed out just enough to make the tests pass.
c

Cicero

11/30/2020, 2:08 PM
Interesting, any suggestions of where I can see something like this working? Or a tutorial of some sort on “how to basic”?
s

Sam

11/30/2020, 3:00 PM
No tutorials that I know of other than basic KMM stuff. To add a jvm target just specify it in your gradle file and add a
jvmMain/kotlin/com.myproj
and
jvmTest/kotlin/com.myproj
folder structure in the same folder that has your common and android folders. Here’s the part of my gradle file with the jvm target using kts.
Copy code
kotlin {
    jvm()
    android()
You can invoke it from the command line with
./gradlew mymodule:jvmTest
or through IntelliJ
🌟 1
2 Views