What would be the best way to add firebase to a KM...
# multiplatform
a
What would be the best way to add firebase to a KMP + Compose Multiplatform App that targets Android and iOS. I want to use the firebase official android and iOS libraries with a custom expect and actual implementation... What woukd be the right architecture to do this?
h
s
s
Since Firebase is not an integral part of the platform (Android/iOS), use plain dependency inversion. Define an interface in commonMain for what you need. Implement it in your androidApp and iosApp using the native Firebase SDKs, and inject it into the shared Kotlin code (code in commonMain) Using expect/actual is less flexible and more cumbersome for such a relatively large API.
๐Ÿ‘ 2
In the mean time, vote for Google to implement a KMP library for Firebase https://firebase.uservoice.com/forums/948424-general/suggestions/46591717-support-kotlin-multiplatform
๐Ÿ‘ 6
๐Ÿ‘๐Ÿป 1
906 Views