Import one KMM module into another and expose it's classes to iOS

560 Views Asked by At

I'm trying to bundle couple KMM modules into one and make them accessible in iOS. I have moduleA and it imports moduleB like so:

val commonMain by getting {
        dependencies {
            api(project(mapOf("path" to ":moduleB")))
        }
    }

In android, if I import moduleA, I can also directly access classes from moduleB. But on iOS, I can only see classes from moduleA. Is there a way to get moduleB classes visible in iOS as well without moving everything into moduleA?

1

There are 1 best solutions below

0
Martin On BEST ANSWER

You need to manually configure the native framework to export the modules you want accessible to iOS:

    framework {
        ....
        transitiveExport = true
        export(project(":moduleB"))
    }

See also: https://akjaw.com/modularizing-a-kotlin-multiplatform-mobile-project/