Hey <@U2VU05RC4> sorry to ping you directly but I ...
# multiplatform
j
Hey @russhwolf sorry to ping you directly but I was reading through Kermit docs and was wondering if you knew how I'm supposed to get a logger instance like this example is showing in a comment?
I'm also wondering if this exposed API will work if we're using a XCFramework with swift package manager and not cocoapods, as the docs also say the cocoapods export is required
m
Fyi there's a #touchlab-tools channel now for touch lab library support
j
thank you Michael! I'll start using that 😄
m
I can also answer you question for you lemme just double check the docs to refresh my memory
So that bit i think is just left as an exercise to the reader since it sort of depends on your architecture. For example in KampKit they get an instance through koin with a tagged helper function in iosMain so if youre using a custom logger instance and koin thatll probably be the best way to go. If youre using static logging you can just export the
kermit-simple
module and theres ios helper functions in there that you can call directly statically, they should show up as like
LoggerKt.v
etc
If youre not using koin or static you can also just do the config on the kotlin side and provide a way for ios to easily get a reference to it however you prefer
j
I believe we'll want to use the static logger (at least while I'm researching). Based off my experimentation I'm guessing if we're using swift package manager and not cocoapods that
LoggerKt.v
wouldn't be exposed to swift? As exposing via:
Copy code
cocoapods {
  framework {
    export("co.touchlab:kermit:2.0.0-RC4")
    export("co.touchlab:kermit-simple:2.0.0-RC4")
  }
}
Doesn't change our output XCFramework that's generated. And I don't get any references to
LoggerKt
from Swift. But I guess we could get a reference like you mentioned by doing something like:
Copy code
import co.touchlab.kermit.Logger

object OurSharedLogger {
  fun d(message: String) {
    Logger.d(message)
  }
}
From
commonMain
m
Yea i think it's probably a difference between cocoa pods and spm. Iirc i think there's a way to export a Gradle dep through spm but i don't remember how.
j
Yeah that makes sense, thanks for the support!
r
For SPM, you can export when you declare your framework using basically the same syntax
Copy code
targets.withType<KotlinNativeTarget> {
    binaries {
        framework {
            export(...)
        }
    }
}
m
Yea that rings a bell now. Thanks for the assist Russel hope i didn't get anything wrong lol
j
Ooo great to know, thanks Russell