https://kotlinlang.org logo
c

Christian Sousa

04/03/2020, 9:29 AM
How do you guys get over the
unresolved reference: platform
in a mpp project? It seems that this happens according to the weather or something like that, sometimes it works fine and I can use autocomplete for the
platform
but other time it simply doesn’t. I already tried invalidating caches and restart, tried removing some folder that I saw in a random stackoverflow thread, but it still happens.
a

Artyom Degtyarev [JB]

04/03/2020, 10:42 AM
Hello! Can you tell which IDE and Kotlin versions you’re using here? Also, what’s the project structure, is it different from the default multiplatform with one common and multiple platform-specific source sets?
c

Christian Sousa

04/03/2020, 10:44 AM
Hello! I tried both Android Studio 3.6.1 and the latest EAP of InteliJ. I’m using Kotlin 1.3.70. The project is similar to the default multiplatform, one commonMain, one androidMain and one iosMain.
And I have this:
Copy code
iosX64()   // for iOS Simulator
    iosArm64() // for iOS arm64 devices



    sourceSets {
        iosMain {
            dependencies {
                implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$coroutines_version"
                implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version"
                implementation "org.jetbrains.kotlinx:kotlinx-serialization-properties-native:$serialization_version"
                implementation "io.ktor:ktor-client-ios:$ktor_version"
                implementation "io.ktor:ktor-client-core-native:$ktor_version"
                implementation "io.ktor:ktor-client-serialization-native:$ktor_version"
            }
        }

        configure([targets.iosX64, targets.iosArm64]) {
            compilations.main {
                source(sourceSets.iosMain)
            }
        }
    }

    cocoapods {
        // Configure fields required by CocoaPods.
        summary = "My Lib"
        homepage = "<https://google.com>"

        // The name of the produced framework can be changed.
        // The name of the Gradle project is used here by default.
        frameworkName = "MyLib"
    }
a

Artyom Degtyarev [JB]

04/03/2020, 1:14 PM
Ok, I think the problem here can be caused by
iosMain
source set is not interpteted as native sometimes. Usually IDE assume only leaf nodes of sourceSets dependency tree as a native source set, while in your case things go a bit more complicated. If this “common ios” construction is really needed for your case, maybe it would be better to use target shortcuts?
103 Views