General question about project structure for KMM, ...
# multiplatform
q
General question about project structure for KMM, does it make any difference (like build time, or restriction in expanding to web in the future) if you have a top-level KMM module which includes all the other modules as a dependency versus multiple KMM modules (as separate features) at the top level ? Root • android-app • ios-app • shared -user -products -routines -entries
j
Generally speaking, multi module helps build times (gradle). That being said, your frontends would probably include a single KMM right? At most other smaller KMMs would be included by the main KMM module? From my POV - The above structure looks good
q
yeah, so i tried creating the KMM modules inside
shared
but had trouble building, saw some issue when running packForXCode “cannot convert URL”. So just to clarify, I’ll have the smaller KMMs at the top level, but included in the
shared
module ? i can build okay with them at the top level.
m
@Qracle I’ve tried to build iOS app with multiple shared modules but I was not able to do so. I’ve started with the simple case:
common-shared
module and
feature-shared
module (feature was dependent from common). The issue was that after building the iOS framework the classes from
common-shared
was not visible in the iOS project. In fact only the once used in
feature-shared
was visible. Later I’ve change the building method from packForXCode to Multiplatform Swift Package but the results was the same. Please let me know if you will be able to workaround this issue.
q
so you have (
android-app
,
ios-app
) ->
feature-shared
->
common-shared
, but classes from
common-shared
aren’t showing up ?
from my understanding, you would only need to utilize the
feature-shared
since it has the dependencies it needs from
common-shared
m
Yes the project structure you provided is exactly my case. Well my problem was that if I wanted to add another module
feature2-shared
and for example extract (from both shared features) some common model classes to
common-shared
then I could not be able to access those classes in
ios-app
. But anyway I’ve done some research today and I found that dependencies of shared modules could also be exported to the ios framework - link. So that is probably resolving my case 🙂
🙌 1
q
Ah, so if
common-shared
had a model class like
Dog
you want to be able to reference that in
ios-app
?
m
yes
q
i actually need that configuration too, thanks for the link!
m
no problem, I’m realy happy that I found it now when my project is in an early stage