How to access swift class in kotlin. Sample code g...
# multiplatform
a
How to access swift class in kotlin. Sample code given below. I'm working on KMM
public
*class* FirebaseRemoteConfigurations {
*var* remoteConfig: RemoteConfig!
*func* initializeRemoteConfig() {
remoteConfig = RemoteConfig.remoteConfig()
*let* settings = RemoteConfigSettings()
settings.minimumFetchInterval = 0 remoteConfig.configSettings = settings }
*func* fetchConfig() {
*let* remoteConfigString = remoteConfig["application_configuration"].stringValue
// [START fetch_config_with_callback] remoteConfig.fetch { (status, error) -> Void
in
*if* status == .success {
print("Config fetched!")
*self*.remoteConfig.activate { changed, error *in*
print(remoteConfigString)
}
} *else* {
print("Config not fetched") print("Error: \(error?.localizedDescription ?? "No error available.")") } } // [END fetch_config_with_callback] } }
p
Idk if this is the best solution but what we do is just define an interface in kotlin and then inject a swift class that implements that into koin
👍 1
m
@Pearce Keesling so far this has been the best approach for me in order to inject Swift implementations. @Ammar Abdullah unless you want to add Cocoapods remote package and rewrite this file using Kotlin introp
a
Sure will look at this
p
Just came across this as another option. No idea how good it is though https://github.com/ttypic/swift-klib-plugin
m
@Pearce Keesling not possible to add remote dependency on Firebase