kotlin-multiplatformcinterop

Kotlin multiplatform project depending on another one with cocoapods


I have a kotlin multipltform library which has several cocoapods

cocoapods {
    ....
    pod("gRPC/GRPCCore", grpcVersion)
    pod("gRPC-ProtoRPC", grpcVersion)
    pod("Protobuf", "3.15.8")
    // etc
}

I published this library to artifactory (maven) and the ios target contains all the klib's for the cinterop'ed pods.

I have a second Kotlin Multiplatform Library where I wish to consume the previous "core" library.

    iOSTarget("ios") {
        binaries {
            framework {
                baseName = "SecondSharedLib"
                export("first.shared.lib:1.0.0")
                xcf.add(this)
            }
        }
    }
    sourceSets {
        val commonMain by getting {
            dependencies {
                api("first.shared.lib:1.0.0")
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
            }
        }
        val androidMain by getting {
            dependencies {
            }
        }
        val androidTest by getting {
            dependencies {
                implementation("junit:junit:4.13.2")
            }
        }
        val iosMain by getting {
            dependencies {
            }
        }
        val iosTest by getting
    }

When linking ios however the pod modules are not found.

ex: ld: framework not found gRPC_ProtoRPC

I also tried redeclaring the pods to no avail.

Is what I am trying to do even possible? does anyone have any suggestions?

Note: I am not an iOS developer so please be harsh if my understanding is off


Solution

  • For anyone dealing with a nested multiplatform library where the base library relies on the cocoapods plugin, I had to link all the frameworks via the linker opts as well as redefine all the cocoapods so that the frameworks would be available for linking.