[KMM] Copy bundle for XCFramework

I am working on a Kotlin Multiplatform project currently. We are using Moko Resources (GitHub - icerockdev/moko-resources: Resources access for mobile (android & ios) Kotlin Multiplatform development) to create a shared directory of resources. This works great with FAT Frameworks, however we have a requirement to use XCFrameworks. I’m not very familiar with iOS and the framework situation, so forgive my ignorance.

Right now it seems something is going wrong when we build our XCFramework, as running the app shows a commainMain.MR is not available, so I think our bundle is not being copied correctly.

Here is our fatFramework Gradle task:

        register("buildFatFrameworkWithResources", TestFatFramework::class) {
        val debugMode = "DEBUG"
        val mode = System.getenv("CONFIGURATION") ?: debugMode
        destinationDir = buildDir.resolve("xcode-universal-framework")
        group = "Universal framework"
        description = "Builds a universal (fat) $mode framework"

        from(iosArm64Framework, iosX64Framework)
        dependsOn(iosArm64Framework.linkTask)
        dependsOn(iosX64Framework.linkTask)
    }

And our XCFramework task

        register("buildXcFrameworkWithResources") {
        dependsOn("deleteXcFramework")
        val mode = "DEBUG"
        val frameworks = arrayOf("iosArm64", "iosX64").map {
            kotlin.targets.getByName<KotlinNativeTarget>(it).binaries.getFramework(mode)
        }

        inputs.property("mode", mode)
        dependsOn(frameworks.map { it.linkTask })
        group = "Universal framework"
        description = "Builds a universal (xc) $mode framework"

        frameworks.first().outputFile.listFiles()
            ?.asSequence()
            ?.filter { it.name.contains(".bundle") }
            ?.forEach { bundleFile ->
                project.copy {
                    from(bundleFile)
                    into("$xcFrameworkPath/${bundleFile.name}")
                }
            }

        doLast {
            val buildArgs: () -> List<String> = {
                val arguments = mutableListOf("-create-xcframework")
                frameworks.forEach {
                    arguments += "-framework"
                    arguments += "${it.outputDirectory}/${project.name}.framework"
                }
                arguments += "-output"
                arguments += xcFrameworkPath
                arguments
            }

            exec {
                executable = "xcodebuild"
                args = buildArgs()
            }
        }
    }

I’m not too sure what needs to be changed to make it work correctly.
Appreciate any help!