[英]IOS Swift SwiftUI Firebase “No default Storage bucket found. Did you configure Firebase Storage properly?”
[英]iOS Swift Firebase Storage error “No default Storage bucket found”
在嘗試像這樣設置對我的 Firebase 存儲的引用時:
let storage = FIRStorage.storage()
我看到以下錯誤:
uncaught exception 'NSInvalidArgumentException', reason: 'No default
Storage bucket found. Did you configure Firebase Storage properly?'
據我所知,一切都設置正確。
我已經使用 Firebase 初始化了應用程序,沒有任何問題:
import Firebase
import UIKit
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
// Use Firebase library to configure APIs
FIRApp.configure()
return true
}
不確定我是否遺漏了一些明顯的東西,從我一直在關注的教程來看,這應該非常簡單。 無論哪種方式,任何見解都將不勝感激! 提前致謝。
其他設置信息:
看來我過早地調用了 Firebase。 我將引用調用移動到函數中:
func uploadToFirebase(data: Data) {
let ref = FIRStorage.storage().reference(withPath: "images/demoPic.jpg")
...
}
一切都在順利進行——感謝@mgtla 提供線索!
希望在遵循 Firebase 教程后為其他發現本文的人發布更新。
applicationDidFinishLaunchingWithOptions 有時可能需要更長的時間才能運行,並且不會在應用程序其他區域(即 ViewController)中的代碼運行之前完成運行。
因此,您可能會收到諸如“尚未配置默認 Firebase 應用”之類的錯誤消息。 或“未找到默認存儲桶。您是否正確配置了 Firebase 存儲?” 因為Firebase 應用尚未配置。
這個答案詳細說明了解決這個問題的方法。 本質上,您需要將 FirebaseApp.configure() 語句添加到 AppDelegate 中的覆蓋 init() 語句中,如下所示:
override init() {
super.init()
FIRApp.configure()
// not really needed unless you really need it FIRDatabase.database().persistenceEnabled = true
}
希望這可以幫助!
這是根 Firebase 存儲參考:
let storageRef = FIRStorage.storage().reference()
當我將 Firebase Storage 添加到我現有的 iOS 應用程序時,我遇到了這個問題。
您需要重新生成GoogleService-Info.plist
文件,該文件現在將正確包含“STORAGE_BUCKET”鍵,並在您的項目中更新它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.