Swift macOS Firebase

佩特·西波斯(PéterSipos)

我有一个启用了Firebase的IOS应用。
现在我目前正在尝试向该项目中添加macOS swift应用程序,但我不知道该怎么做。
(我知道可以将IOS应用程序移植到macOS,但是我想要两个功能不同的独立应用程序,一个用于IOS,另一个用于macOS)

Firebase Admin中没有选项(据我所知)添加macOS应用程序,因此我在Firebase Admin中创建了一个新的IOS应用程序,并尝试使用macOS应用程序项目进行设置。(很可能这是我整个问题的问题)

运行macOS项目时,我在AppDelegate中收到以下错误:

尚未配置默认的Firebase应用。在应用程序初始化中添加[FIRApp configure];FirebaseApp.configure()在Swift中)。

引发了一个未捕获的异常

无法获取FirebaseApp实例。在使用Firestore之前,请先致电FirebaseApp.configure()

由于未捕获的异常“ FIRIllegalStateException”而终止应用程序,原因:“无法获取FirebaseApp实例。使用Firestore之前,请先致电FirebaseApp.configure()

我曾经用过FirebaseApp.configure()我的算法applicationDidFinishLaunching
我也进口了每个豆荚,但没有任何帮助。

pod 'Firebase'
pod 'Firebase/Core'
pod 'Firebase/Analytics'
pod 'Firebase/Auth'
pod 'FirebaseDatabase'
pod 'Firebase/ABTesting'
pod 'Firebase/Database'
pod 'Firebase/Firestore'
pod 'FirebaseFirestore'
pod 'Firebase/Functions'
pod 'Firebase/Messaging'
pod 'Firebase/RemoteConfig'
pod 'Firebase/Storage'

我的问题是我可能做错了什么?
或Firebase不支持macOS应用程序?
如果是,那么如何将现有的Firebase IOS项目与新的macOS Swift应用程序一起使用?

佩特·西波斯(PéterSipos)

有人在GitHub中遇到了同样的问题我也被告知,我的很多Pod实际上是ios Pod,所以我将Podfile更改为:

pod 'FirebaseCore'
pod 'FirebaseAuth'
pod 'FirebaseDatabase'
pod 'FirebaseStorage'

我也将我的AppDelegate文件更改为此:

override init() {
    FirebaseApp.configure()
    Database.database().isPersistenceEnabled = true
}

func applicationDidFinishLaunching(_ aNotification: Notification) {
    Database.database().reference()
}

这似乎可以解决我的问题(目前,我希望这是最终解决方法)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章