Thread
#multiplatform
    m

    mattinger

    3 weeks ago
    I’m sure this has been asked, but i wanted to confirm my suspicions that kotlin-reflect is a jvm only library. I have things i would like to do with meta programming, but i’m not sure i could make that work on iOS code (i’m not targeting JS, just android and ios), Swift itself has the Mirror functionality for reflection, but it’s my understanding that kmm doesn’t really deal in swift and compiles directly to down to binary code.
    Trevor Stone

    Trevor Stone

    3 weeks ago
    There is basic reflection support for kotlin native. If you can do things at compile time instead of runtime you can also look at KSPhttps://kotlinlang.org/docs/ksp-overview.html https://kotlinlang.org/docs/ksp-multiplatform.html #ksp
    m

    mattinger

    3 weeks ago
    @Trevor Stone I’m basically thinking retrofit like things. Inspecting the annotations at runtime and generating interface implementations based on it. Not necessarily to execute http requests, but similar type approach.
    Trevor Stone

    Trevor Stone

    3 weeks ago
    https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.reflect/ it looks like Annotations can be used in kotlin native but I haven't done it before. Personally, I would go down the ksp route to generate the code at compile time with KotlinPoet vs using reflection but seems like both could be viable
    Random library I found (written in java) trying to do a retrofit like solution but at compile time. https://github.com/zskamljic/rest-ahead
    e

    ephemient

    3 weeks ago
    https://github.com/Foso/Ktorfit uses ksp to generate implementations for retrofit-like APIs