I'm currently playing around with Kotlin multi platform feature and have a minor problem. When I start gradle multi-platform project in Intellij and use keywords 'actual' and 'expect', they are underlined in red and show message "The feature "multi platform projects" is experimental and should be enabled explicitly"
How can I explicitly enable multi platform feature? Thanks
I'm currently playing around with Kotlin multi platform feature and have a minor problem. When I start gradle multi-platform project in Intellij and use keywords 'actual' and 'expect', they are underlined in red and show message "The feature "multi platform projects" is experimental and should be enabled explicitly"
How can I explicitly enable multi platform feature? Thanks
Share Improve this question asked Feb 18, 2018 at 13:12 P. HabzanskyP. Habzansky 2902 silver badges8 bronze badges 3- @MarkoTopolnik doesn't work, throws message "Could not find method multiplatform() for arguments [enable] on object of type org.jetbrains.kotlin.gradle.dsl.ExperimentalExtension." – P. Habzansky Commented Feb 18, 2018 at 13:49
- It was a shot in the dark, anyway, by analogy to enabling experimental coroutines. – Marko Topolnik Commented Feb 18, 2018 at 14:03
- @MarkoTopolnik I know, I saw it too, it would probably make the most sense – P. Habzansky Commented Feb 18, 2018 at 14:40
3 Answers
Reset to default 12Finally found an answer. In Intellij in Preferences->Build, Execution, Deployment->Compiler->Kotlin Compiler append to Additional command line parameters: field command -Xmulti-platform.
If you are using Gradle you can enable the multi-platform feature by adding -Xmulti-platform
flag to compiler arguments in
build.gradle:
tasks {
compileKotlin {
kotlinOptions.freeCompilerArgs += "-Xmulti-platform"
}
}
build.gradle.kts:
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.freeCompilerArgs += "-Xmulti-platform"
}
This warning can be suppressed by adding the below line to gradle.properties
file
kotlin.mpp.stability.nowarn=true
Here the complete project.properies file for reference
kotlin.code.style=official
xcodeproj=./iosApp
android.useAndroidX=true
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.enableDependencyPropagation=false
kotlin.mpp.stability.nowarn=true