KMM, XCFramework, Apple Silicon

I managed to generate a XCFramework with Kotlin 1.5.31 containing targets for ios-arm64, ios-x86_64-simulator.

Now I’m trying to add an Apple Silicon target, iOS Simulator Arm64, but I’m failing to figure out how to do it.

With the following build.gradle.kt, it generates a fat framework for iOS Simulator containing x86_64 and arm64 archs (I checked with lipo) and the step for creating the XCFramework fails with an error on xcodebuild: error: the path does not point to a valid framework

kotlin {
    val xcf = XCFramework()

    ios {
        binaries {
            framework {
                baseName = xcFrameworkName

    iosSimulatorArm64 {
        binaries.framework {
            baseName = xcFrameworkName

    sourceSets {
        val iosMain by getting
        val iosTest by getting

        val iosSimulatorArm64Main by getting
        val iosSimulatorArm64Test by getting

I’ve also tried to run lipo -remove and manually run the xcodebuild command but it still complained.

It seems to me that by adding the iosSimulatorArm64 block, the compiler generates a fat binary, which is not adequate for XCFrameworks.

Does anyone have suggestions to make a XCFramework with targets iOS, x86 iOS Simulator and Arm64 iOS Simulator? Thanks

1 Like

Did you manage to solve it? I have exactly the same problem :slight_smile:

I ended up generating each target separately and then created a script which runs something like this:

xcodebuild -create-xcframework 
 -framework LibiOSArm64.framework -debug-symbols LibiOSArm64.framework.dSYM
 -framework LibiOSSimulatorArm64.framework -debug-symbols LibiOSSimulatorArm64.framework.dSYM
 -framework LibiOSX64.framework -debug-symbols LibiOSX64.framework.dSYM
 -output Lib.xcframework