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

Raed Ghazal

09/24/2023, 9:35 AM
Hey, QQ: we have 2 android directories, one the android app, and one in the shared directory, how to decide which classes goes where?
v

Vlad

09/24/2023, 9:47 AM
Android directory(module) is androidApp. shared is KMP directory(module). We put everything we can into shared. The android app as dull as possible
p

Paul Woitaschek

09/24/2023, 10:13 AM
It really depends on why you do multiplatform. Which other targets do you support?
r

Raed Ghazal

09/24/2023, 10:18 AM
@Paul Woitaschek iOS
@Vlad yeah that makes senes ,thank you!
p

Paul Woitaschek

09/24/2023, 10:19 AM
Then it still depends. Can you give an example what mind of code you want to add?
r

Raed Ghazal

09/24/2023, 10:21 AM
so the story is that I already have an Android project that i started migrating into a KMM project so I can release it on iOS as well I started questioning it once i wanted to move the datastore class, and wasn’t sure if this should be in the android module or the shared module since its android specific and I’m going to implement something else on iOS (native data store)
p

Paul Woitaschek

09/24/2023, 10:25 AM
In this case I'd move it to Android. If each platform gets its own implementation for something, it makes more sense there. • People will see it in androidMain and immediately know it's only Android • People will actively search for an iOS counterpart when trying to understand the code. That's good • You won't increase the iOS binary size. That's also good. We have already hit size 75mb (or was it 50mb)? Framework limit once.
r

Raed Ghazal

09/24/2023, 10:27 AM
in Android you mean androidApp module or android directory in shared module?
p

Paul Woitaschek

09/24/2023, 10:27 AM
Do you have a monorepo?
r

Raed Ghazal

09/24/2023, 10:28 AM
you mean single repository for the whole project android and iOS?
p

Paul Woitaschek

09/24/2023, 10:28 AM
Yup
r

Raed Ghazal

09/24/2023, 10:28 AM
yes
p

Paul Woitaschek

09/24/2023, 10:28 AM
Then I'd make it dependant on where the iOS implementation is going to live
In Swift - in the Android folder In iosMain - in the shared folder
r

Raed Ghazal

09/24/2023, 10:29 AM
probably iosMain
then yeah I’m going with the shared folder
p

Paul Woitaschek

09/24/2023, 10:32 AM
👌
3 Views