So I just compiled a small Kotlin/native fat frame...
# kotlin-native
s
So I just compiled a small Kotlin/native fat framework for our iOS team. It included 2 small private libs, kotlinx.coroutines, ktor, and kotlinx.serialization. The entire compiled framework when added to the iOS app only increased app size by 1.1 MB. That’s fantastic! Way better than I anticipated. It’s so good I’m actually a bit skeptical that the iOS dev measured things correctly. Does this sound right?
k
is it static?
s
I’m not sure what you mean by static honestly.
Can frameworks be static or not static? I’m compiling via
Copy code
tasks.create("debugFatFramework", org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask::class) {
        baseName = iosFrameworkName

        // The default destination directory is '<build directory>/fat-framework'.
        destinationDir = buildDir.resolve("fat-framework/debug")

        // Specify the frameworks to be merged.
        from(
            iosX64.binaries.getFramework("RELEASE"),
            iosArm64.binaries.getFramework("RELEASE")
        )
    }
k
yes, they can be static
if you have an
isStatic = true
in your individual framework config
s
I do not
Would static make it larger, or smaller (smaller I’m assuming?)
what is the advantage of static vs non-static?
k
you can read all about static linking, but one advantage is that it only includes symbols are used
k
I did kotlin size tests recently. To get a real sense of what it’ll do to the app I wound up pushing it to app store connect to get the size estimates. Just some basic string functions with no libraries added ~150k. KaMP Kit, with a bunch of libraries, added ~1.3 meg. This will vary quite a bit depending on what you’re doing, of course. I haven’t really published results because there’s a lot more analysis to do, and I’m working on other things at the moment. Those were all with static frameworks.
The static vs dynamic may not be a huge distinction, as konanc only outputs binary for things you use, so some of that reduction is baked in, but the reality is more complicated than that.
s
lol
im testing to see if static outputs a larger framework now.
k
I have a forked version of the cocoapods plugin so I can play with that stuff. Debugging with static frameworks wasn’t working. Now I can toggle that easier.
s
@kpgalligan give me the short of it. Should I be compiling static frameworks to share with my iOS team or dynamic?
k
I’m just learning about static/dynamic myself
You probably want static, though
s
thx
ok
k
The only issue is, as mentioned, debugging out of the box. Can’t.
That’s still being researched, though
s
but with dynamic you can debug out of the box?
k
Yeah. The dsyms are attached. Need to figure out how to reattch them. However! “Out of the box” still means local compile.
You can’t share binary from another machine