I am trying to used 2 KMM packages inside of my iOS app however its not being referenced correctly.
Here is my dependency structure:
iOSApp
+ KmmPackageOne
+ KmmPackageTwo
KmmPackageOne
+ KmmPackageTwo
Here are the example files im trying to use in the iOSApp
// In KmmPackageOne, class Foo.kt
class Foo {
fun bar() { ... }
}
// In KmmPackageTwo, class Buzz.kt
class Buzz(
private val foo: Foo
) {
...
}
When adding them to the iOS app, it doesn't understand that parameter foo is from KmmPackageOne
// in swift class
...
val buzz = Buzz(foo: Foo())
the following error is thrown
Argument type `Foo` does not conform to expected type `KPTFoo`
I've assumed KPT means KmmPackageTwo. So it seems XCode has added a layer of abstraction to the KmmPackageTwo in KmmPackageOne.
build.gradle of KmmPackageOne
sourceSets {
commonMain {
kotlin.srcDir('src/commonMain/kotlin')
dependencies {
implementation("locationOf:KmmPackageTwo:+")
}
}
If you're trying to import 2 Xcode Frameworks that were built with Kotlin separately, you can't do that. I just answered a similar question today.
https://stackoverflow.com/a/67403855/227313
You need to build 1 Xcode Framework that has all of your Kotlin modules.