Hi all. We are experimenting by building a `kmp-co...
# multiplatform
c
Hi all. We are experimenting by building a
kmp-compose-lib
that will provide common compose-ui and other features to an iOS and android app. We split the umbrella library in multiple modules, for example, one module for our
design-system
and another for our
home-tab
.
Copy code
umbrella-project
-- kmp-lib
-- compose-ui
---- design-system
---- home-tab-root
and where
kmp-lib
relevant gradle script parts looks like:
Copy code
val xcf = XCFramework("KmpLib")
    val iosTargets = listOf(iosArm64(), iosSimulatorArm64())

    iosTargets.forEach { iosTarget ->
        iosTarget.binaries.framework {
            baseName = "KmpLib"
            isStatic = true
            export(projects.composeUi.homeTabRoot)
            export(projects.composeUi.designSystem)
            xcf.add(this)
        }
    }
The problem we are facing is that when creating the XCFramework the assemble task takes forever until eventually it throws a heap OOM. We are running on macos, 32 gb, and are assigning 8G to the heap and daemon. Has anyone faced a similar issue?
Copy code
Compilation failed: Java heap space

 * Source files: 
 * Compiler version: 2.2.0
 * Output kind: FRAMEWORK
a
XCFramework is definitely the slowest part of the KMP workflow for me. How big are your projects? Have you increased the heap space for gradle?
c
It is not big enough 😄 a couple of thousands lines of code max, as we are starting the experiment and starting to port some parts of the app, ui and business logic. I had 8G on the heap, and tried with 16G ... but I have an M1 32Gb ... so I am limited that way
In case it helps ... As part of our design-system, we had a set of 3k icon files defined as lazy ImageVector...removing that, makes it compile on time again ... still, I would expect kmp to handle 3k files with no issues 🥲, now the project has exactly 105 files ... and it takes 4 minutes to compile ... that is something unaffordable I think. 105 files, in 5 modules (one module is the umbrella, 4 modules have the actual logic)
Copy code
kmp-lib (umbrella - compose)
design-system (compose)
navigation (compose)
ui (compose)
domain
and with no big dependencies other than
compose
(we also have ktor)
t
Hey, can you please report the OOM as a bug to YouTrack? If you can share the reproducer that will be most helpful, otherwise recording the JFR for OOM will help pinpoint the source of breakage:
Copy code
-Dorg.gradle.jvmargs="-Xmx8g ... other jvmargs ... XX:+FlightRecorder -XX:FlightRecorderOptions=stackdepth=256 -XX:StartFlightRecording,settings=profile,filename=/path/to/oom.jfr"
You can also make sure you have linkage caching enabled and build debug binaries for development to speed up build.
👍 1