【发布时间】:2025-12-25 12:15:17
【问题描述】:
我在网上尝试了许多不同的资源,但它们似乎都使用了应用程序委托文件,我完全糊涂了。
我想要做的就是从 Cloud Firestore 读写到我的 swift 应用程序
我已经通过包管理器安装了 firebase 和 firestore,但似乎找不到 Firestore 管理器
import SwiftUI
import Firebase
@main
struct RecipyApp: App{
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@StateObject var firestoreManager = FirestoreManager()
var body: some Scene{
let viewModel = AppViewModel()
WindowGroup{
ContentView()
.environmentObject(viewModel)
.environmentObject(firestoreManager)
}
}
}
class AppDelegate: NSObject, UIApplicationDelegate{
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
FirebaseApp.configure()
return true
}
}
我的代码。
我可以做些什么来解决我的问题?
非常感谢
【问题讨论】:
-
不要添加代码的屏幕截图,而是将实际代码添加到问题中。要捕获错误消息,请右键单击红色指示器和“Reveal in Issue Navigator”。
-
@FrankvanPuffelen 是不是更好
-
你必须制作 Firestone 管理器
-
@loremipsum wdym
-
我所说的它不是来自 Firebase,你必须做到。您可能从某个地方复制了此代码。回到那里阅读教程、发布、观看视频等。
标签: swift firebase google-cloud-firestore