Hello what are the best practices to implement multi-module Kotlin on iOS?
We have multiple apps, each app can dependent on multiple feature frameworks. Here's an example diagram. From what I read is that the iOS App2 might see 2 versions of the classes in Module1... Because the frameworks are being compiled separately... Any suggestion/workarounds on how to solve this problem?
Kurt Renzo Acosta
09/17/2020, 5:28 AM
Yep. I encountered the issue where you'll have two classes. What I did was to make a configuration module which just gets all the modules needed for the iOS app so that iOS only consumes one module and there are no duplicate classes. I wasn't able to achieve the level of granularity I have with Android but it lets me modularize my code so I'm happy with that setup for now.
09/17/2020, 7:24 AM
That's what I was thinking of doing... Are you creating swift frameworks dependent on that shared Kotlin module?
If yes, I assume that you always use the same name for your Kotlin framework. So when you implement Feature1 (Swift Framework) you just use the Kotlin Module1.
And when you use it in iOSApp2, you provide the "merged" Kotlin Module which contains the classes from Kotlin Module1... And the linking should work... right?
Kurt Renzo Acosta
09/17/2020, 7:31 AM
Sadly no. Our setup was just simple on iOS and no modularization so we just had to worry about getting it in the app. I remember the iOS dev I was working with tried to do a setup that you are trying and I remember that he tried to just use the configuration module on each framework which I was against cause it seemed bad but I think he got it working. I’m not with them so I guess you’ll have to try it out to find out.
09/17/2020, 7:34 AM
Ok I will try this approach. I agree it's bad but it's our only way if we have multiple apps that are going to use the same modules...