Hey devs, I’ve been working on a kmp project and...
# multiplatform
p
Hey devs, I’ve been working on a kmp project and I’ve successfully added Firebase dependencies for Android. Now, I’m trying to add Firebase dependencies for iOS. Since Firebase doesn’t directly support KMP, I’ve added the iOS Firebase dependency using the Xcode package manager. However, I’m unsure how to write Kotlin code that can share Firebase-related logic between Android and iOS, especially since iOS dependencies are only accessible in .swift files. Most resources online suggest using third-party libraries like GitLive, but I prefer to use the official Firebase libraries for both platforms. As a native Android developer, I’m fairly new to KMP and iOS development, so any guidance would be greatly appreciated. Thanks.
s
p
@Swapnil Musale I don’t want to use the third party libs for firebase. Is there any way to consume only official firebase dependency for android and ios, and share logic?
s
No official firebase multiplatform support yet.
You have to it on yourself
p
You will need to declare an interface in kotlin and implement it in swift. Here is an example: The interface: https://github.com/pablichjenkov/macao-marketplace/blob/dev/auth-firebase%2Fsrc%2FiosMain%2Fkotlin%2Fcom%2Fmacaosoftware%2Fplugin%2Faccount%2FFirebaseAuthKmpWrapper.kt The swift implementation: https://github.com/pablichjenkov/firebase-kmp/blob/main/FirebaseAuthKmp%2FSources%2FFirebaseAuthKmpWrapperImpl.swift I have it in 2 different projects because I wanted to create a library that has 2 integrations, 1 KMP and one as a swift package. But if you don't need that, it is easier if they are both in the same project.
p
Thanks man 👍
👍 1