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

Sam

05/16/2020, 11:46 AM
I'm setting up a multiplatform, multi-module project. I want to have a module
A
there which doesn't target any specific end-platform itself, but is acting as a "common" library which can be added into another multiplatform module
B
. Module
A
would make use of another multiplatform libs (stdlib, coroutines and sqldelight). It's the module
B
that will target
Android
and
iOS
. It seems it can't be done using
kotlin-multiplatform
plugin as a tooling. 1. Am I right? 2. Is there another tooling/plugin available that will allow me to configure such a "common" module?
u

Ugi

05/16/2020, 1:17 PM
From my experience, you are right, but your pure kotlin module A will need to define platform targets, such as
linux
jvm
iosX64
, etc if you want to use them in your module
B.
k

Konstantin Petrukhnov

05/16/2020, 1:54 PM
How do you add A to B? submodule? artifact? etc?
r

russhwolf

05/16/2020, 3:48 PM
There’s no such thing as a common module which doesn’t declare targets. Set up the same targets in
A
that you need in
B
and it will work
👀 1
s

Sam

05/16/2020, 4:49 PM
@Konstantin Petrukhnov I was trying using implementation(project(":A")) in build script of B
Classes of A are not visible in B, however they are visible in the end-app module which uses B as dependency
@russhwolf I'm trying with Android target in both A and B
Copy code
kotlin {
    android()
}
then plugging in A into B as dependency
api(project(":A"))
. and in the and B is plugged into android app. In the android app classes from A are available, in B not 🤔
using implementation instead of api doesn't help
r

russhwolf

05/16/2020, 5:59 PM
Just to sanity-check. Are you certain classes aren’t visible, or is it that they don’t autocomplete. It might be an IDE issue. Try manually calling things (make sure you have the right imports) and see if it builds from command-line/gradle. If not, would have to see the project in more detail to be able to say much more
👀 1
s

Sam

05/16/2020, 6:46 PM
Argh 🤦‍♂️ You are 100% right. It's an IDE issue. Command line build is successful even though IDE can't find the classes. Thank you for guiding me into right direction.
👍 1
r

russhwolf

05/16/2020, 6:48 PM
Cool. If you have a simple reproducer, maybe throw it on youtrack if there’s not already a similar issue being tracked
s

Sam

05/16/2020, 6:50 PM
My bad I was using AS 🙈 in IntelliJ everything is okay
😭 1
4 Views