Generated a new project from template > Kotlin ...
# kotlin-native
j
Generated a new project from template > Kotlin > Native | Gradle. Compile and run fine. Then I add a coroutines runBlocking line to the generated sample app:
Copy code
package sample

import kotlinx.coroutines.runBlocking

fun hello(): String = "Hello, Kotlin/Native!"

fun main() {
    runBlocking {
        println(hello())
    }
}
The error is “unresolved references” to coroutines and runBlocking. Heres the build.gradle file, which just adds the coroutine dependencies. What did I do wrong?
Copy code
plugins {
    id 'org.jetbrains.kotlin.multiplatform' version '1.3.61'
}
repositories {
    mavenCentral()
}

kotlin {
    macosX64("macos") {
        binaries {
            executable {
               entryPoint = 'sample.main'
                runTask?.args('')
            }
        }
    }
    sourceSets {
        macosMain {
            dependencies {
                implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3'
            }
        }
        macosTest {
        }
    }
}
k
there is no declaration for
runBlocking
in coroutines common
you have to create the expect/actual yourself
j
Its working after I changed the dependencies to implementation ’org.jetbrains.kotlinxkotlinx coroutines core native1.3.3