KotlinMultiplatformExample
KotlinMultiplatformExample copied to clipboard
Start
Known problems
You might see: Configuration on demand is not supported by the current version of the Android Gradle plugin since you are using Gradle version 4.6 or above. Suggestion: disable configuration on demand by setting org.gradle.configureondemand=false in your gradle.properties file or use a Gradle version less than 4.6.
Also: Error:The modules ['android', 'mobile'] point to the same directory in the file system. Each module must have a unique path.
Hacks
Multiplatform development in Kotlin still have some limitations. This is why I had to apply some hacks which are temporary.
Native dependencies
Cannot declare Gradle dependencies on Konan yet, so we just include sources.
https://youtrack.jetbrains.net/issue/KT-25582
Names generated by JS
Generated names for functions have mashed names. This is why from:
interface QuotationView {
fun showQuote(quote: Quote)
}
We have function required named showQuote_4z1tej$
https://youtrack.jetbrains.net/issue/KT-25583
Mixing Kotlin and Swift dependencies is not allowed in Konan
We cannot do:
class ViewController : UIViewController, QuotationView {
override fun showQuote(quote: Quote) {
textView.text = quote.text
authorView.text = quote.person
}
//...
}
We need to do instead:
class ViewController : UIViewController {
private val quotationView = object : QuotationView {
override fun showQuote(quote: Quote) {
textView.text = quote.text
authorView.text = quote.person
}
}
// ...
}