How to speed up the task `compileKotlinMetadata` ?...
# multiplatform
s
How to speed up the task
compileKotlinMetadata
? I set
org.gradle.parallel=true
in settings and even call it with --parallel, but this tasks takes 3 minutes for me - even on a beefy
M1 Pro
(8 performance cores) it tooks as long as on an M1. So this tasks does not benefit from more cores... What can I do to cut down compiling time here?
1
c
you could try running a build scan
s
So far I run a --profile and this task comes up as the single one that takes so long and does not seem to benefit from parallelisation.
Ok, did that... It has no suggestions for me. 🤷‍♂️
This just takes very long and I don't see how to speed up the task.
g
Not 100% sure but I believe the compilation of 1 module (gradle) is mono-threaded. So if you can cut your shared modules in more modules (without too much dependencies between them) it should be able to use multi-threads.
s
Ok, sounds reasonable. So in my case multiple XCFrameworks instead of just one big. 🤔
g
You can have multi-modules and get a big XCFramework. For example I use:
Copy code
val xcf = XCFramework("MyLib")
ios {
    binaries {
        framework("MyLib") {
            isStatic = true
            projectsToExport().forEach { export(it) }
            xcf.add(this)
and
Copy code
fun projectsToExport() =
    rootProject.allprojects
        .filter {
            it.childProjects.isEmpty() &&
                <your export rules> &&
                it != project
        }
I have that configuration in my "top-level module" (mainly used for exporting rules) that depends on many libraries.
without
export(..)
the XCFramework will contain classes transitively used by the "top-level module" but renamed with the module name. Adding
export(..)
ensure all classes of the package will be provided, and without the name trick.
s
Thank you 🙂
👍 2