Thread
#multiplatform
    j

    juh juh

    1 month ago
    Are there runtime methods to check which platform code is running on?
    Landry Norris

    Landry Norris

    1 month ago
    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.landrynorris😛latform-info:1.1.0, I believe. That was kind of a one-off thing, so I don’t remember the exact version.
    Landry Norris

    Landry Norris

    1 month ago
    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

    juh juh

    1 month ago
    Thanks!
    j

    jw

    1 month ago
    the stdlib function is only for kotlin/native targets
    Matthias Geisler

    Matthias Geisler

    1 month ago
    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.
    Landry Norris

    Landry Norris

    1 month ago
    I’ve also seen people define a common interface, then implement it in Android and iOS, passing it via Koin.
    Matthias Geisler

    Matthias Geisler

    1 month ago
    I think that is the better way to go