Quick question about KMM XCFramework builds. By de...
# multiplatform
o
Quick question about KMM XCFramework builds. By default, Kotlin generates all architectures (arm64, arm64-simulator, x86_64), which is great for compatibility but slows down CI a lot. Has anyone here configured the build to generate only arm64 for CI? or ./gradlew sharedembedAndSignAppleFrameworkForXcode does it by default only arm ?
kodee greetings 1
r
I think you can just comment out the unnecessary architecture from shared gradle build
o
???
what is your point?
d
I think if you search this slack this has already been answered before but what Rizwan is saying is that you can also exclude architectures yourself if you wanted with something like
Copy code
listOfNotNull(
        iosArm64(),
        iosSimulatorArm64().takeUnless { YOUR_RUNNING_IN_CI_FLAG },
    ).forEach { iosTarget ->
        iosTarget.binaries.framework {
            baseName = "Shared"
            isStatic = true
        }
    }
in your gradle script. From memory there are already some optimisations that the Kotlin team has built in tho
👍 1
o
sir how about this
Copy code
val frameworkName = "shared"
    val xcf = XCFramework(frameworkName)
    targets.filterIsInstance<KotlinNativeTarget>()
        .forEach {
            it.binaries {
                framework {
                    baseName = frameworkName

                    val includeToXCF = when (project.activeArch) {
                        Arch.ARM -> {
                            this.target.name.contains("iosArm64") || this.target.name.contains("iosSimulatorArm64")
                        }

                        Arch.ARM_SIMULATOR_DEBUG -> {
                            this.target.name.contains("iosSimulatorArm64") && this.debuggable && !this.optimized
                        }

                        Arch.X86 -> {
                            this.target.name.contains("iosX64")
                        }

                        Arch.ALL -> {
                            true
                        }
                    }

                    if (includeToXCF) {
                        xcf.add(this)
                        logger.lifecycle("framework '${this.name}