Does anyone know how to reduce the .xcframwork fil...
# multiplatform
p
Does anyone know how to reduce the .xcframwork file size generated from the KMM library?
k
First of all, mark as
internal
all the symbols (classes, fields, methods) you can
j
@KamilH is right; to check what symbols are exported, you can use the 'nm' command, and also 'class-dump' from here: http://stevenygard.com/projects/class-dump/
k
Or you can inspect
<framework_name>.h
file in the build folder, in my case it’s this one:
Copy code
shared/build/xcode-frameworks/Debug/iphonesimulator17.2/shared.framework/Headers/shared.h
your goal would be to strip it as much as you can
p
Thanks, that helps.
a
if you r using cocoapods you can disable embedBitcode
Copy code
cocoapods {
        version = ""
        summary = ""
        homepage = ""
        name = ""

        framework {
            baseName = ""
            isStatic = false
// this line
embedBitcode(org.jetbrains.kotlin.gradle.plugin.mpp.BitcodeEmbeddingMode.DISABLE)
        }
}
p
Thank you for the suggestion @Ahmed na but I am not using cocoapods.
j
It's still worth adding embedBitcode("disable") to binaries { framework { ... though, I guess...
👌 1
p
Can I use embedBitcode even if I am not using cocoapods?
j
Yes
But not in the cocoapods { ... } thing
This is what I have in our project: ios { binaries { framework { // bitcode is deprecated embedBitcode("disable")
1
p
Thanks, I will give it a try.
j
One more thing for this framework thing; but that is for some additional fine-tuning is this one: freeCompilerArgs += _listOf_("-linker-options", "-S -x -exported_symbols_list " + file("libs/exported-symbols.list").toString())
Where the exported-symbols.list is a list of symbols I really really need to keep in the framework, and others are stripped. Use with care, though.