I am trying to start an interactive shell for my Kotlin/Native test app, but get null when I write input using readLine(). (It works in Kotlin/Jvm )
// Main.kt
fun main() {
println("Tell your name:")
val name = readLine()
println("Hello, $name!")
}
// build.gradle.kts
plugins {
kotlin("multiplatform") version "1.6.10"
}
group = "angelos"
version = "1.0"
repositories {
mavenCentral()
}
kotlin {
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" -> macosX64("native")
hostOs == "Linux" -> linuxX64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
nativeTarget.apply {
binaries {
executable {
entryPoint = "main"
runTask!!.standardInput = System.`in`
}
}
}
sourceSets {
val nativeMain by getting
val nativeTest by getting
}
}