Are there runtime methods to check which platform ...
# multiplatform
j
Are there runtime methods to check which platform code is running on?
l
Not by default. You’d have to use expect/actuals. I created a library for this https://github.com/LandryNorris/PlatformInfo
I published it to maven at io.github.landrynorrisplatform info1.1.0, I believe. That was kind of a one-off thing, so I don’t remember the exact version.
l
You learn something new every day.
Is this available on Android, or just Kotlin/Native? I don’t see it autocomplete like it does in iosMain.
j
Thanks!
j
the stdlib function is only for kotlin/native targets
m
You can do it via expect/actual...but the better question is why you wanna do that? You could implement the what you want in the platform source.
l
I’ve also seen people define a common interface, then implement it in Android and iOS, passing it via Koin.
m
I think that is the better way to go