After searching this forum, I couldn’t find that anybody has raised this question before.
Why is that even a minimum ( ‘Hello world’ type ) KMM app project create shared ios framework binary of sized around 6 MB even in release mode ? Even for a single architecture ( arm64 )
When I add Ktor library for http & web socket support, release binary size of shared part for ios reached to 19 MB ( not a fat file just for single architecture ). And more strange thing is debug binary is smaller ( 11 MB ).
I’m talking about the part usually named as shared.framework/shared . To be exact, I built below reference project provided by Ktor.
with “io.ktor:ktor-client-websockets:$ktor_version” added to commonMain.
These are dynamic libraries I don’t see anyway to compile shared part to a static library for ios in KMM. Appreciate if anyone is aware.
This is an unusually large size. Even a large JS processing engine like v8, would not consume this much in binary size. Is this normal for KMM or did I miss anything ?
I’m trying to create library for distribution which other application can include.
Why would you care about intermediate library size in the first place? If that stuff do not get shrinked when you compile the app for release, well that’s a problem then, but otherwise why bother?
It didn’t look like size is going to reduce once built the app. Because it’s a dynamic library already built and linked in release mode (by KMM). This is why I asked whether there is a way to get this shared part built into static library. ios static libraries are large but once linked only required parts get into to the final app contributing the least possible size increase to the app.
It’s a library I am distributing. Size matters. Just to write some common code less than 2000 lines, to share between ios & android, I don’t think 3 MB - 19 MB is a worth size. My library is already around 15 MB in size due to millions of C++ lines from a big opensource library covering 2 architecture slices. If I go with KMM like above, then my ios lib size will shoot up to ( 20 x 2 ) + 15 = 55 MB rendering it useless.
No issue with Android, coz it’s not native but JVM code.
If KMM assumes that developers will use it end to end in order to create the whole app. It doesn’t add a good value over frameworks like Flutter. True value is the ability to create reusable components ( libraries ) which are usable across all other technologies in my opinion.
No, I did not. I gave up KMM for my project for now. Thanks for the reply, I’m checking this post time to time, in order to see whether there is any answer.
Minimum size I could achieve for ios was : 2.4 MB without adding any dependency.
The moment I add kotlinx.serialize for minimal json parsing size goes 2.7 MB.
One good thing noted was, as long as you don’t add external gradle dependencies, binary size stay fixed at around 2.5 MB for like up to 1000 LOC ( beyond that I didn’t test ). Using Kotlin standard library such as various collections has no noticeable impact.
Please share details if anybody could get iOS binary file size below 2 MB. Anyway I have moved my shared code to ‘Rust’ since sometime where I am achieving below 1 MB for binary size at the cost of difficult communication with objc & jvm code.
For rust minimal size without any dependencies is like : 500 KB but you can’t work without adding few dependencies in rust.
These sizes are for Shared framework as a dynamic library in release mode without Bitcode. That is a good way to measure effective final app size growth.