最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Kotlin - Multi platform feature - Stack Overflow

programmeradmin0浏览0评论

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
Add a comment  | 

3 Answers 3

Reset to default 12

Finally 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
发布评论

评论列表(0)

  1. 暂无评论