in samples <https://github.com/JetBrains/compose-m...
# multiplatform
e
in samples https://github.com/JetBrains/compose-multiplatform/blob/master/examples I see that usually there are 2 places in the project where platform specific files are placed. Sometimes they are in the androidMain/iosMain folders inside the common module, but sometimes they are in the separate android/ios module. Is there any criteria where this files should be normally?
p
If you plan to ship it with your module for reusability then leave it in the library module. If you plan to only use it in the specific platform Application module then put it there. Common, shared, are just names, they are basically modules. Modules that have targets and you can compile and ship it to some consumer Application module. In fact an Application module is a normal module that only uses one target. But is just convention, for instance you can still add other targets to androidApp or jvmApp/desktopApp
e
I understand that I put files that should be reused in common and platform specific into corresponding platform folder. But for example I don’t understand the difference between putting file into a separate android module or into androidMain inside the common module. In both cases it will be accessible only on a specific platform.
p
That's right. Let's say you are making a library and the library depends on specific platform code. For the consumer of the library you want to ship those classes that are specific to each platform. What I meant to say in above comment is that
common
or
shared
are just libraries too. So you decide what to ship with it
e
Got it. If I am making just one app, where should I normally place platform specific files in common module or in a separate module? As I understand I can even can avoid having a separate android module.
p
I personally prefer placing it in the common module for the reason that I might have another App that also consumes that same common module. So in such a case I just add the common dependency to gradle and that's it. Otherwise I would have to copy/paste files from one project to the other
h
If you really really just want to not reuse parts of your app you could put anything your app module, but I would recommend to split your app into multiple modules because you will often reuse some parts for other applications too.
e
Thanks guys!