This issue is previously posted here https://github.com/JetBrains/kotlinconf-app/issues/56 but got no reply, so I reposted it here.
In the old blog https://hadihariri.com/2017/11/10/multiplatform-projects-with-kotlin/, it talked about how to use expect in the common module, and implement it with actual in separated android/js module. Also, sample code here https://github.com/hhariri/kotlin-mpp-sample
In this repo (considered the latest tech to use kotlin/native in the multiform platform), the actual implementation must be essentially implemented in the same ‘:common’ module, which is kinda awkward.
Here is my scenario.
In this repo, there is an interface
org.jerbrains.kotlincof.storage.Settings declared in the common module, and implemented in the Android module and ios sourceset which is also in the common module.
I’m trying to change the interface to expect-actual, since the
Settings interface only has one implementation on one platform. Only to find I have to do actual Settings in the jvmMain sourceset, like this.
I want to implement the Settings in my android/ios module for multiple reasons:
- my Settings implemetation depends lots of Android librarys
- my Settings implemetation depends lots of Android module source code
- my Settings implemetation depends on my Android application config
There is one problem: when using expect-actual across modules, one must implement actual in the ios module and possibly in Swift/Objective-c, which make it impossible for kotlin compiler to enforce the
BTW(小声BB): If we could write kotlin file in swift module like writing kotlin file in java module, that would be perfect.
Thanks in advance!