I had this exact topic this morning 😄 I'm using Framework instead of Cocoapods, but should be no difference.
• You can create multiple KMM modules same as any other gradle module
• If module
module-a
depends on
module-b
, add following to the
commonMain
source set of `module-a`:
implementation(project(":module-b"))
• Add exports for each module you depend on (this might be a bit different for you, but look for an export function
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "shared-base"
export(project("module-b"))
}
}
The important lesson for me was that you can only include one KMM module into your iOS app. It only exposes the classes inside this module and not classes of any other module you added with
implementation
. To export the classes of a module you added with
implementation
as well, you need to add a
export(project(...))
directive