I'm trying to set up TimeTravelServer in the iOS p...
# mvikotlin
t
I'm trying to set up TimeTravelServer in the iOS project following construction in the documentation but still can not import the TimeTravelServer. Tried to sync gradle and build many times (in android studio and Xcode). Please help!
a
Can you show the full build.gradle file?
t
Copy code
import com.codingfeline.buildkonfig.compiler.FieldSpec.Type.BOOLEAN
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.DEBUG
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.RELEASE

plugins {
    kotlin("multiplatform")
    kotlin("native.cocoapods")
    android("library")
    ksp()
    buildKonfig()
}

kotlin {
    android()
    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64(),
    ).forEach {
        it.binaries {
            framework {
                export(Dependencies.ArkIvanov.MVIKotlin.mvi_kotlin_timetravel)
            }
        }
    }

    cocoapods {
        version = Versions.state_holder_lib_vname
        summary = "Shared state holder library to share model between android and iOS"
        homepage = "Link to the Shared state holder Module homepage"

        ios.deploymentTarget = "13"
        podfile = project.file("../ios-pos-app/Podfile")

        framework {
            baseName = PkgName.shared_state_holder
        }

        xcodeConfigurationToNativeBuildType["Debug"] = DEBUG
        xcodeConfigurationToNativeBuildType["Release"] = RELEASE
    }

    sourceSets {
        all {
            languageSettings.optIn("kotlin.experimental.ExperimentalObjCName")
        }

        val commonMain by getting {
            dependencies {
                with(Dependencies.JetBrains.Coroutines) {
                    implementation(coroutine_core)
                }
                implementation(Dependencies.JetBrains.Kotlin.kotlinx_datetime)
                implementation(project(PkgName.pos_sdk.toProjectPath()))
                implementation(project(PkgName.common.toProjectPath()))

                with(Dependencies.ArkIvanov.MVIKotlin) {
                    implementation(mvi_kotlin)
                    implementation(mvi_kotlin_main)
                    api(mvi_kotlin_timetravel)
                    implementation(mvi_kotlin_extensions_coroutine)
                }
                implementation(Dependencies.AndroidX.Core.data_store)
            }
        }

        val androidMain by getting

        val iosX64Main by getting
        val iosArm64Main by getting
        val iosSimulatorArm64Main by getting
        val iosMain by creating {
            dependsOn(commonMain)
            iosX64Main.dependsOn(this)
            iosArm64Main.dependsOn(this)
            iosSimulatorArm64Main.dependsOn(this)
        }
    }
}

android {
    namespace = PkgName.sharedStateHolder
    compileSdk = Versions.android_compile_sdk_version
    defaultConfig {
        minSdk = Versions.android_min_sdk_version
    }
}

buildkonfig {
    packageName = PkgName.sharedStateHolder
    objectName = "StoreConfig"

    //Local host config, default (type, name, value)
    //Change flavor in root gradle.properties
    defaultConfigs {
        buildConfigField(BOOLEAN, "DEBUG", "true")
    }

    defaultConfigs("product") {
        buildConfigField(BOOLEAN, "DEBUG", "false")
    }

    defaultConfigs("staging") {
        buildConfigField(BOOLEAN, "DEBUG", "true")
    }
}
a
First of all, something looks wrong here. E.g. you only export
mvikotlin-timetravel
, but in the Swift code you also use
DataStoreKt
. It looks like XCode uses another Gradle module, not this one. Another idea, it could be a bug in Cocoapods plugin. There were multiple occurrences when some dependencies are not visible in Xcode. I recommend switching to Regular Framework if possible (e.g. if you are not using Pod dependencies in Kotlin).
Oh, is DataStoreKt is defined in the module itself?
t
DataStoreKt is my shared code, it's not count. But let me try your suggestion
a
If you could provide a reproducer of this issue, this would be very useful. I really would like to catch this bug in Cocoapods plugin and report it to JetBrains. This is not the first time.
E.g. you could try stripping all your code, and see if the problem is still there, and then upload to GitHub or drop an archive here.
t
I'll try. Sometimes issues appear and then are gone but I don't know why 😂
I solved it by creating expect/actual function to start the time travel server.
a
Hmm, interesting! Thanks for sharing!
t
Do you know how to fix this error?
run the client in macos by gradle cmd is ok
Copy code
./gradlew :mvikotlin-timetravel-client:app-desktop:run
but package to dmg then install will go error
a
Hmm, thanks for reporting, never seen this error before. Sorry. I will try checking it.
Btw, you can also use the idea plugin.
t
Thank you
a
I couldn't reproduce the issue. Would you be able to provide a full stack trace?
Also, if you still have that crash, could you please try the following patch and see if it fixes the issue? If it does, I would commit the fix.
t
I realize I just need restart my computer then this issue is gone. But I can not capture any event even in android or ios. So I just used LoggingStoreFactory to debug.
Anyway, let me try the patch then try to use the TimeTravel client again. Currently I'm happy with logging 😊