Large shared framework size for ios

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.

1 Like

Did you find any solution to your problem?

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?

Thanks for the reply.

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.

I have the same question.

Hi, I think there is no problem with binary size. Release binary is big because it also contains bitcode. If you will disable the bitcode. put


you will see that binary size will be reduced significantly. Also, it’s possible to compile “static framework”, just add

isStatic = true

in binaries.framework.