Are there any conditional compile strategies? Some...
# kotlin-native
a
Are there any conditional compile strategies? Something like
If (android) {a=andA} else if (ios) {a=iosA}
. I want to use interfaces to separate some platform-specific logic, then compile them according to different platform
Well, I think I can just implement the interface in Kotlin with the iOS API then inject the generated framework at swift side. Same for android. No need for this kind of check.
o
You could also deploy
expect/actual
mechanism and compile different sources adhering to same contracts on different platforms
a
@olonho Thanks! This is actually better. But I thought the multiplatform project hasn’t landed on KN yet?
o
Plugin support not there yet, keywords shall be supported
a
@olonho Thanks for the hints! I just tried. IDEA said that
multiplatform project is experimental and should be enabled explicitly
. I tried to add
expect "enable"
in
kotlin{ experimental{} }
by the side of
coroutines "enable"
, seems not the right way. Any ideas?
o
try
-Xmulti-platform
compiler switch
a
gradle build -Xmulti-platform
will yield
Unknown command-line option '-X'.
. Or is it a
kotlinc
parameter, but don’t know how to build with that yet. Will try later
i
Yes, it's a compiler switch and you may pass it via the gradle plugin using `extraOpts`:
Copy code
konanArtifacts {
    program('foo') {
        extraOpts '-Xmulti-platform'
    }
}
But multiplatform support was added after the 0.5 KN release so you need to use either a compiler built from current master or set
konan.version
in your
gradle.properties
to some development version (e.g.
konan.version=0.6-dev-822
)
👍 1
a
Thanks! @0wl