Thread
#multiplatform
    j

    Jeff Tycz

    1 year ago
    I have a KMP library that uses Ktor, 99.9% of the code is in the common package and the only thing in the android and ios is to set the ktor engine. I am not sure about how to provide the necessary dependencies to be used for my library to be used in ios and android. do I have to build a gradle dependency for ios and android just to get the ktor engine and then the common dependency with all the code?
    e

    edenman

    1 year ago
    i just define my NetworkClient class in the common library, then my android app passes an
    HttpClientEngine
    into the constructor when it builds it
    all the dep graph stuff stays in the android app, shared module just defines the interfaces and logic
    j

    Jeff Tycz

    1 year ago
    How does that work in ios though I don't think you can just pass it in because the app side wouldn't know about the dependency right?
    e

    edenman

    1 year ago
    full disclosure: our iOS app isn’t using the kmp library yet
    but i assume you could define a helper in your iosMain and add the dep to the specific engine there too
    i just re-read your question and now i’m not sure at all what you’re asking
    j

    Jeff Tycz

    1 year ago
    Haha sorry I don't know how to correctly ask what I am thinking. Basically I need to create a Gradle dependency that a 3rd party app can use to import I to their projects Gradle file like one normally would for Android. So do I need an "Android" dependency for the KMP androidMain an iOS dependency for iosMain and a common dependency for commonMain even if the Android and iOS code is literally just one actual variable
    e

    edenman

    1 year ago
    yeah you lost me again. maybe put up a sample repo that shows what you’re thinking?
    j

    Jeff Tycz

    1 year ago
    https://github.com/tyczj/Tweedle/tree/multiplatform here is my project I am trying to convert to KMP. basically what do I need to build for people to be able to use it on ios and android for now
    s

    Sam

    1 year ago
    That looks about right. For iOS distribution, you have two choices. You can distribute as a klib to be consumed by other KMP projects or as a dynamic framework. An app would typically use your framework only if it doesn’t have any other Kotlin code. An app can have more than one Kotlin framework in it but they will pretend not to know each other. They’re separate worlds.