https://kotlinlang.org logo
Title
m

maskipli

06/29/2021, 5:47 PM
hy folks, am trying to use Decompose and MVI libs, and have issue
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
ObservableValue, LifecycleRegistryKt
sample from https://github.com/JetBrains/compose-jb/tree/master/examples/todoapp
a

Arkadii Ivanov

06/29/2021, 7:18 PM
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

maskipli

06/30/2021, 2:57 AM
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
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

lehakorshun

06/30/2021, 4:27 AM
@maskipli Hi, when you work with cocoa, you should export as this
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)
                }
        }
:thank-you: 1
use it in kotlin section
m

maskipli

06/30/2021, 5:51 AM
Thanks @lehakorshun...