iOS Swift Firebase 存储错误 "No default Storage bucket found"
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 上创建并链接了该应用程序
- 我已经生成并添加了 google plist
- 我已经用 CocoaPods 安装了库:
- 豆荚'Firebase/Core'
- 豆荚'Firebase/Storage'
我已经使用 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
}
不确定我是否遗漏了一些明显的东西,从我一直遵循的教程来看,这应该是非常简单的。无论哪种方式,任何见解都将不胜感激!提前致谢。
其他设置信息:
- Xcode版本:8.2.1
- CocoaPods 版本:1.2.1
这是根 Firebase 存储参考:
let storageRef = FIRStorage.storage().reference()
看来我调用 Firebase 的时间太早了。我将引用调用移到了函数中:
func uploadToFirebase(data: Data) {
let ref = FIRStorage.storage().reference(withPath: "images/demoPic.jpg")
...
}
一切都很顺利 - 感谢@mgtla 提供线索!
想要 post 为其他在遵循 Firebase 教程后找到这篇文章的人更新。
applicationDidFinishLaunchingWithOptions 有时可能需要更长时间才能 运行,并且不会在应用其他区域(即 ViewController)中的代码之前完成 运行ning 运行宁。
因此,您可能会收到 "The default Firebase app has not yet been configured." 或 "No default Storage bucket found. Did you configure Firebase Storage properly?" 之类的错误,因为 Firebase 应用尚未配置。
修复此问题的方法详见 本质上,您需要将 FirebaseApp.configure() 语句添加到 AppDelegate 中的 override init() 语句,如下所示:
override init() {
super.init()
FIRApp.configure()
// not really needed unless you really need it FIRDatabase.database().persistenceEnabled = true
}
希望对您有所帮助!
当我将 Firebase 存储添加到我现有的 iOS 应用程序时,我 运行 遇到了这个问题。
您需要重新生成 GoogleService-Info.plist
文件,该文件现在将正确包含“STORAGE_BUCKET”键,并在您的项目中更新它。
在尝试像这样设置对我的 Firebase 存储的引用时:
let storage = FIRStorage.storage()
我看到以下错误:
uncaught exception 'NSInvalidArgumentException', reason: 'No default
Storage bucket found. Did you configure Firebase Storage properly?'
据我所知,一切都已正确设置。
- 我已经在 Firebase 上创建并链接了该应用程序
- 我已经生成并添加了 google plist
- 我已经用 CocoaPods 安装了库:
- 豆荚'Firebase/Core'
- 豆荚'Firebase/Storage'
我已经使用 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
}
不确定我是否遗漏了一些明显的东西,从我一直遵循的教程来看,这应该是非常简单的。无论哪种方式,任何见解都将不胜感激!提前致谢。
其他设置信息:
- Xcode版本:8.2.1
- CocoaPods 版本:1.2.1
这是根 Firebase 存储参考:
let storageRef = FIRStorage.storage().reference()
看来我调用 Firebase 的时间太早了。我将引用调用移到了函数中:
func uploadToFirebase(data: Data) {
let ref = FIRStorage.storage().reference(withPath: "images/demoPic.jpg")
...
}
一切都很顺利 - 感谢@mgtla 提供线索!
想要 post 为其他在遵循 Firebase 教程后找到这篇文章的人更新。
applicationDidFinishLaunchingWithOptions 有时可能需要更长时间才能 运行,并且不会在应用其他区域(即 ViewController)中的代码之前完成 运行ning 运行宁。
因此,您可能会收到 "The default Firebase app has not yet been configured." 或 "No default Storage bucket found. Did you configure Firebase Storage properly?" 之类的错误,因为 Firebase 应用尚未配置。
修复此问题的方法详见
override init() {
super.init()
FIRApp.configure()
// not really needed unless you really need it FIRDatabase.database().persistenceEnabled = true
}
希望对您有所帮助!
当我将 Firebase 存储添加到我现有的 iOS 应用程序时,我 运行 遇到了这个问题。
您需要重新生成 GoogleService-Info.plist
文件,该文件现在将正确包含“STORAGE_BUCKET”键,并在您的项目中更新它。