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

humbledroid

03/18/2024, 9:31 AM
I was experimenting with KMM, and got a use case that I was looking at alot of threads and issues on issuetracker. Considering fully modularised existing iOS and Android apps, which heavily rely on modularisation for obvious reasons, and lets assume, that we want to extract out some common functionalities like error logging, analytics some common features (only the business logic) to the world of KMM so as to share code among both platforms. lets say we have KMM project/library that as multiple modules like,
:core
which has the whole networking layer, model, which will then be used by another module
:analytics
,
:error-logger
,
:auth-feature
and so on. and then these modules can be consumed in the iOS and android apps. while building a framework/xcframework for iOS side, all of this would get packaged in single xcframework and while consuming in iOS side, we will end up, consuming unnecessary modules in the respective modules in iOS side. like a feature module might not auth module at all, but just error logger, but the framework will have all of it. are there any strategies or something that can be done in order to achieve this, I have gone through a few issues and open issues on youtrack. here https://github.com/JetBrains/kotlin-native/issues/2423 https://github.com/JetBrains/kotlin-native/issues/2423#issuecomment-465384562 https://github.com/JetBrains/kotlin-native/issues/4013 https://youtrack.jetbrains.com/issue/KT-42247
maybe they can be extracted out to 3 separate frameworks instead on one framework that contains all, and respective framework can be used in the necessary modules in iOS app.
as the above approach ends up having a ton of duplicate dependencies in each framework, we can probably have something like extract core as its own framework and the respective frameworks depends on it, this seems more unreal, but not super sure though.
I am also inferring from
<https://kotlinlang.org/docs/multiplatform-build-native-binaries.html#access-binaries>
this, that these can be extracted out as native binaries, and then can be added to native targets, but not super sure about it though.