I have a kmm module (`B`) that depends on another ...
# multiplatform
a
I have a kmm module (
B
) that depends on another kmm module (
A
). However I also need to call
A
from my iOS app. I have a singleton in
A
that I initialise in my app and whose methods I call in
B
. Currently I get a not initialised exception in module B even though I have initialised my singleton in the app. Any Idea how I can fix this? Both the modules are in a single project and I am specifying their path in my podfile.
m
You need to create one framework that merges both modules together (a new module that depends on the other two). Make sure you export the other two modules in the new one. Or just export A in the framework from B. By default a framework from module B has a different copy of module A than the framework from module A.
🙏 1
👍🏻 1
a
So is there no way I can make them use the same copy?
The problem is I might need my kmm module in other kmm modules. So is the only way to do that to create a kmm framework that would simply export all my kmm modules?
a
Since B already depends on A. Build it as a framework marking A as an exported dependency
m
There's a very limited set of things that can be shared. Like you could take a function created from framework A and pass it to framework B, but not classes or interfaces. If this is all for a single app, then the general practice is to create a module that depends on all the modules you want to use in your iOS app.
a
Thanks @mkrussel and @andylamax. Is this a cocapods limitation or one with kmm? and if it is one with kmm are there any plans on fixing it?
m
It's a KMM limitation. I'm not aware of any plans to fix it.
a
There is a ticket for this, and I believe it is in the works. It is not high priority because the current workaround works just well enough. You should just try searching this slack about an umbrella framework
🙌 1
👍 1
🙏 1