Thanks for the comprehensive reply @brunojcm!
sometimes I ended up in a weird state because it assumes you have some experience with iOS development and limitations
Agreed! While that is totally expected when you need to dig deeper in the code, it shouldn’t by something that comes up right after opening a new project, in my opinion.
Part of it was just my ignorance, though, so keep in mind that things improve with time.
Yes, sure - same thing here. This is definitely a great product and it does have a bit of a learning curve - but documentation should be able to make it easier.
While there’s already a considerable amount of documentation, it doesn’t seem to explain the architecture (from what I’ve seen, or I looked in the wrong place).
Some remaining questions/thoughts I have:
-
Which IDE should one use and is that mandatory?
Context: IDEA Ultimate seemed to have some trouble with the project, in the end I followed the documentation and switched to Android Studio - which I’m now also using for the iOS side (at the moment). I could imagine that some things, such as gradle(plugins) might actually require a specific IDE. But also, it’s obvious that Android Studio is better suited for developing and testing android apps.
Reading the documentation, it seems mandatory to use xcode, at least once, on mac (we have macs at work, but I’ve never had to use xcode - an explanation would be welcome). -
How does the compilation process work?
Context: other multiplatform languages, such as C, work differently. Code is effectively switched out depending on pre-processor directives. Some smart IDEs can be preconfigured with the right pre-processor settings so that such switched-out code is ignored.
In KMP, this works differently. Errors still show up and when you look at the code of a different target, it gives the impression that the project won’t compile. The plugin mentioned above solves the errors, which in the end provides a better dev experience than C. -
Why platform X requires plugin/settingsX, but platform Y doesn’t have plugin/settingsY?
Context: This is more of a product decision question on JetBrains’ side. What I mean is, when I look atsrc/build.gradle.kts
, it looks like so more or less:kotlin { ... androidTarget { compilations.all { kotlinOptions { jvmTarget = "1.8" } } } listOf( // why doesn't this look like `iosTarget { ...`? iosX64(), iosArm64(), iosSimulatorArm64() ).forEach { iosTarget -> iosTarget.binaries.framework { baseName = "ComposeApp" isStatic = true } } sourceSets { val androidMain by getting { ... } val commonMain by getting { ... } // why isn't there an `val iosMain ...`? } } android { ... } // why isn't there an ios section?
-
Are existing platform-agnostic/pure-kotlin libraries automatically usable as common dependencies?
Context: When I saw that GitHub - g0dkar/qrcode-kotlin: QRCode Generator implemented in pure Kotlin, I assumed it could be used as a common dependency. I tried it so and ended up with some vague gradle errors. Looked a bit deeper and saw the the author had an androind version and was in the process of releasing an ios one too. Naturally, I’m wondering where are the limitations - is gradle/maven even aware of platform-specific libraries? Is a pure-kotlin library not automatically portable? Why? -
Where does KMP end and platform-specific layer start?
Context: This is effectively what you wrote already and I guess relates to the compilation flow. Kotlin for javascript generates javascript, kotlin for wasm generates assembler. For android, presumably same as java. For ios I’m guessing it’s the same principle as native so I assume it’s automatically adding a platform-specific layer for things like memory management.
Anyway, at this point I think I’ve got the hang of it, so I feel more comfortable looking around.