p

    Peter Hsu

    2 years ago
    Hi all, I have a general question about using libraries. I have a project that exports to iOS, Android, and JS. I needed to pull apollo-graphql into my project. Apollo-graphql only supports iOS and Android at this time. Since there is no JS support, I'm unable to add the library dependency to the "common" sourceSets, so I'm unable to share that work for iOS and Android within my project.. It seems like I could create a separate project/repository that exports the iOS/Android artifacts that I need, but that's pretty heavyweight. Is there a better way to accomplish what I want?
    Kris Wong

    Kris Wong

    2 years ago
    expect/actual a bridge API with an empty implementation for JS
    p

    Peter Hsu

    2 years ago
    That's what I'm hoping to be able to do, but since I'm adding the apollo-graphql as a dependency to the sourceSets/commonMain, it's preventing JS from exporting
    If I add it to sourceSets/androidMain and sourceSets/iosMain, then I wouldn't be able to share the code
    seems like setting up a separate multiplatform module that exports to iOS/Android only is the way to go and to pull those dependencies into sourceSets/iosMain and sourceSets/androidMain
    Kris Wong

    Kris Wong

    2 years ago
    i'm not sure what you mean when you say you wouldn't be able to share the code. are the APIs exactly the same for the iOS and Android SDKs?
    even if they were, which seems highly unlikely, the imports would be different
    or is it a KMP library?
    p

    Peter Hsu

    2 years ago
    it is a KMP library
    Kris Wong

    Kris Wong

    2 years ago
    gotcha
    in that case I would create a
    mobile
    common source set, i.e.,
    mobileMain
    ,
    mobileTest
    p

    Peter Hsu

    2 years ago
    ok, that makes sense, thank you!