I have two Kotlin modules, call them A and B. A us...
# ios
j
I have two Kotlin modules, call them A and B. A uses APIs that B provides: a class from ‘A’ uses another class from ‘B’ in its initializer. However, when I try to initialize the class in ‘A’, it doesn’t want to accept the class because both modules export the API of ‘B’, and they’re not equivalent. How can I do this?
b
it sounds like you might be exporting multiple frameworks to iOS vs just a single shared framework? I tried doing that in the past and came across the same issue. I don't think multiple frameworks like this are supported yet. I'm still just exporting a single shared framework that contains the code from multiple kotlin modules, but exporting the other kotlin modules into it manually.
Copy code
cocoapods {
  framework {
    ...
    export(project(":your-module-name"))
  }
}
s
That must suck for iOS devs right? They want access to one thing in one place, and they need to bring in everything into that project, is that right?
b
If I understand you correctly, yes. There is a lot of pain on the iOS side. But it's tolerable in smaller scale projects. e.g. I want to be able to create a Swift library module that only implements the view code for some Kotlin library module. My only solution here is to have my Swift library module import the Kotlin app+library module, so it can't actually stay scoped to "library".
I ended up just quitting that venture entirely and just have a separate folder in my app for "library" code
s
Which again ends up with "if you need anything from in there, you get the entire thing" right? I wonder, is this something that is a temporary pain point which is worked on, or something that can't really be fixed for some reason?
b
it seems there have been efforts started to address it which get paused/stopped, I think b/c it's very tricky to address
thank you color 1
so, not very temporary.
j
I haven’t ended up trying this yet… I would hope that eventually I can use Kotlin frameworks like I can a Swift/ObjC/C++ framework… but perhaps there are technical reasons I can’t do that yet.