https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
m

Mustafa

05/19/2020, 4:15 PM
Can some explain to me if I wanted to use Firebase SDK for Android and IOS how I could use "expect" and "actual" to realize this? For example with Firestore.
s

Sam

05/19/2020, 7:11 PM
Make a repo object that interfaces with Firestore and don’t expose anything Firestore related to the calling code. The expect code defines the methods available and the actual on each platform works with Firebase in the platform specific way.
c

Chuck Greb

05/19/2020, 10:13 PM
Here's a KMP Firestore implementation that uses expect/actual with mostly extension functions : https://github.com/touchlab/FirestoreKMP
☝️ 1
m

Mustafa

05/20/2020, 12:38 PM
@Chuck Greb yea first and one of 2 libraries that I have found on GitHub before asking this. The library isn't supported and the amount of code required is not worth me forking to maintain. I just want to use Rest API.
@Sam sounds good and easy for Android side but not sure how to do that with iOS side without native firebase library
@Sam could you link me an example doing this for any library?
And thanks for your help!
s

Sam

05/20/2020, 1:41 PM
I don’t have an example. These are the docs on it. https://kotlinlang.org/docs/reference/native/cocoapods.html
7 Views