hy folks, am trying to use Decompose and MVI libs...
# mvikotlin
m
hy folks, am trying to use Decompose and MVI libs, and have issue
Copy code
cocoapods {
        summary = "Shared Module"
        homepage = "Link to the Shared Module homepage"
        ios.deploymentTarget = "14.1"
        frameworkName = "shared"
        podfile = project.file("../iosApp/Podfile")
    }
sourceSets {
sourceSets["iOSMain"].dependencies {
            implementation(Ktor.clientIos)
            implementation(MVIKotlin.kotlin)
            implementation(Decompose.decompose)
        }

sourceSets["commonMain"].dependencies {
            implementation(MVIKotlin.kotlin)
            implementation(Decompose.decompose)
        }
}
why i can't access class of MVI from ios project, like
Copy code
ObservableValue, LifecycleRegistryKt
sample from https://github.com/JetBrains/compose-jb/tree/master/examples/todoapp
a
To access classes from Decompose you need to export it, an example can be found here. The ObservableValue class is just a normal Swift class, you can just copy-paste it.
m
thanks much @Arkadii Ivanov when i combine it with cocoapods, the issue is that it can't use the same framework name as cocoapods and kotlin native . I used this method and it worked
Copy code
ios {
        // native.cocoapods Gradle plugin will declare
        // the binary framework creation.
        // Since, duplicate binary name is not supported,
        // we need to configure the binary settings declared by
        // native.cocoapods plugin to mark the dependency as an
        // exported dependency.
        binaries
            .filterIsInstance<org.jetbrains.kotlin.gradle.plugin.mpp.Framework>()
            .forEach {
                it.transitiveExport = true
                it.export(Decompose.decompose)
                it.export(MVIKotlin.kotlin)
            }
    }
source : https://medium.com/wantedly-engineering/different-approaches-in-consuming-kmm-modules-in-ios-7957c722b114
l
@maskipli Hi, when you work with cocoa, you should export as this
Copy code
targets.withType(KotlinNativeTarget::class.java)
        .all {
            binaries.withType(org.jetbrains.kotlin.gradle.plugin.mpp.Framework::class.java)
                .all {
                    freeCompilerArgs = freeCompilerArgs.plus("-Xobjc-generics").toMutableList()
                    export(Deps.Arkivanov.Decompose.iosArtifact)
                    export(Deps.Arkivanov.MviKotlin.iosArtifactMain)
                    export(Deps.Arkivanov.MviKotlin.iosArtifactLogging)
                }
        }
🙏 1
use it in kotlin section
m
Thanks @lehakorshun...