b

    basher

    3 years ago
    Does anyone here have
    @Serializable
    working on multiplatform building for iOS? Running into this build error:
    cannot access 'Serializable': it is internal in '<http://kotlin.io|kotlin.io>'

    I've checked the existing GH issues where it appeared people just had import/plugin issues, but I think I'm doing that right:

    apply plugin: 'kotlin-multiplatform'
    -
    apply plugin: 'kotlinx-serialization'
    -
    implementation: "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:${versions.serialization}"
    -
    import kotlinx.serialization.Serializable
    Something I'm missing?
    kgonyon

    kgonyon

    3 years ago
    Are you trying to use
    @Serializable
    inside common or native source set? I have it working for my multiplatform project which is building for ios.
    apply plugin: 'com.android.library'
    apply plugin: 'kotlin-multiplatform'
    apply plugin: 'kotlinx-serialization'
    apply plugin: 'maven-publish'
    iosMain {
                dependencies {
                    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$kotlin_coroutines_version"
                    implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$kotlin_serialization_version"
                }
            }
    I had to make sure I was using gradle 4.7 as well.
    b

    basher

    3 years ago
    trying to use it in common
    I'm working without gradle metadata though due to SQLDelight and kotlinx libs using different gradle metadata versions
    @kgonyon i'm now trying this out in a new mpp sample project (using gradle 4.7 and all that), and i'm doing the same thing as you but getting the same error. What other dependencies do you have setup for your common code?
    kgonyon

    kgonyon

    3 years ago
    commonMain {
                dependencies {
                    implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
                    implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlin_serialization_version"
                    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
                    implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
                }
            }
    kotlin_native_version=1.3.11
    kotlin_version=1.3.11
    kotlin_serialization_version= 0.9.1
    kotlin_coroutines_version=1.1.0
    b

    basher

    3 years ago
    ah that was it! i had org.jetbrains.kotlinx:kotlinx-serialization-runtime-common instead of org.jetbrains.kotlinx:kotlinx-serialization-runtime. thanks! this gets me closer to figuring it out in my larger project
    kgonyon

    kgonyon

    3 years ago
    No problem. Glad I could help some.
    d

    Drew

    3 years ago
    @basher I'm also trying to figure out how to do this (except w/ coroutines) when Gradle metadata is disabled (because I need SQLDelight). If you remember, can you let me know when you figure it out?
    b

    basher

    3 years ago
    👍 if I figure it out, i'll def update here 🙂
    Figured it out. For your iOS targets, you need to add
    impelementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native_debug_ios_arm64:${versions.serialization}"`
    impelementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native_release_ios_arm64:${versions.serialization}"`
    use those instead of just plain
    -native
    and then you do the same for sim but
    -iosx64
    d

    Drew

    3 years ago
    @basher nice. It seemed to be working--until I changed some dependencies around (or did a clean build, or something) and then started getting some weird error. ..
    exception: java.lang.IllegalStateException: Could not find "/Users/.../.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-serialization-runtime-native_debug_ios_arm64/0.9.1/b0a5a1202ec09423abf641fd47393aade3172064/kotlinx-serialization-runtime-native_debug_ios_arm64-0.9.1.klib" in [/Users/.../Projects/HelloKotlinMPP, /Users/.../.konan/klib, /Users/.../.konan/kotlin-native-macos-1.0.3/klib/common, /Users/.../.konan/kotlin-native-macos-1.0.3/klib/platform/ios_x64].
    Jonas Bark

    Jonas Bark

    3 years ago
    implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version"
    works fine for me for iOS targets
    d

    Drew

    3 years ago
    @Jonas Bark even without having enabled Gradle metadata?
    b

    basher

    3 years ago
    @Drew hm not sure about that sorry
    d

    Drew

    3 years ago
    Yeah, no worries. I’ll figure it out! MPP seems so tricky right now with all the dependency management
    Ashley Figueira

    Ashley Figueira

    3 years ago
    @Drew indeed.
    d

    Drew

    3 years ago
    I really want to dive in and create some cool stuff--but it’ll only be useful / beneficial in my org w/ stuff working decently on iOS… and it seems like iOS/native is just not there for dependency management and coroutines (in my experience anyway). Guess I can learn enough to contribute a fix back to the repos though