I am attempting to use the firebase database in my watchKit app. I have developed this feature on my iPhone application but have found it difficult to do the same on my Watch app. When I attempted to import firebase into the VC class in watch app, it is creating an error no such module 'firebase'
.
Is it possible to use firebase inside a watch app?
Sadly there is no
Firebase
support forwatchOS2
andwatchOS3
due to the fact that there's no support forCFNetwork
in these versions ofwatchOS
andFirebase
is highly dependent on this framework. Source (thanks for the link @FrankvanPuffelen in comments).You have two alternatives:
Firebase REST API
directly from your watch app.Firebase
communication from theiPhone
app and use theWatchConnectivity
framework to send the relevant changes to your watch app.Depending on your exact use case, you could choose any of the two. The main advantages/disadvantages of these two are that the
WatchConnectivity
framework is quite limited as in when it can be used. Both of your apps needs to be running at least in the background for theWatchConenctivity
framework to work. On the other hand, if you choose to use theREST API
, you don't need the watch app to communicate with theiPhone
counterpart, the watch app can directly get theFirebase
data using network requests. However, in this scenario, the network usage will be bigger, since you will need to essentially fetch the same information both for theiPhone
and watch apps.