I have 2 multi-platform library projects A and B w...
# multiplatform
j
I have 2 multi-platform library projects A and B where B depends on A and both Android and iOS depends on B. How can I make classes from library A visible to Android and iOS through library B?
m
mark A as an "api" dependency of B
1
B/build.gradle.kts:
Copy code
dependencies {
  api(project(":a"))
}
a
^ in
commonMain
source set.
☝️ 1
1
j
Do I need to add
import A
too in my ios app or just
import B
? I’m not able to use it 🤔 I’ll check on android
m
Ah, for iOS you'll most likely need to export in the framework too
let me check
j
I can’t see classes from project A on android either. I said project but I’m using package dependencies
api("com.jeantuffier:statemachine:2.0.6")
. My android app imports the shared library through a string dependency and the ios app through a manually built xcframework. Should
api(...)
still work in that case?
m
Might be a tooling issue? IntelliJ/AS are quite wobbly when it comes to multiplatform and completion
I'd focus on Android first (because the JVM tooling is usually a bit better), try to build the project and see if that works (even with red underlines in Studio)
If it does, you might have to make sure all your dependencies have an
android()
target
that helps the IDE sometimes
j
My library A targets the jvm while library B targets android, that might also be an issue
m
I've definitely seen IDE issues with this (although I think it built fine IIRC)
j
turned out I was simply missing the maven repo configuration in gradle, since the library is hosted on github. It works on Android an iOS now. Thanks for the help!
👍 1