【发布时间】:2021-08-10 03:46:03
【问题描述】:
我目前正在按照此链接将 Firebase 添加到 iOS 应用程序的步骤:https://console.firebase.google.com/u/1/project/fir-198a3/overview
我已经能够成功地执行这些步骤,直到到达我需要添加“初始化代码”的部分。它指出我需要在主 AppDelegate 类下面添加代码。但在我的 .xcworkspace 文件(使用终端添加 Cocoapods 后创建的文件)中,我没有看到原始文件中的任何代码。
那么我的问题是:当您的应用启动时,我应该怎么做才能连接 Firebase?
import UIKit
import Firebase
content_copy
This is the code I am supposed to copy: (I am running the latest Xcode version)
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions:
[UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
content_copy
return true
}
}
【问题讨论】:
-
请参阅peterfriese.dev/swiftui-new-app-lifecycle-firebase,详细了解如何执行此操作。
标签: ios firebase swiftui appdelegate