【问题标题】:iOS Swift Firebase Storage error "No default Storage bucket found"iOS Swift Firebase 存储错误“未找到默认存储桶”
【发布时间】:2017-09-15 02:17:10
【问题描述】:

在尝试像这样设置对我的 Firebase 存储的引用时:

let storage = FIRStorage.storage()

我看到以下错误:

uncaught exception 'NSInvalidArgumentException', reason: 'No default 
Storage bucket found. Did you configure Firebase Storage properly?'

据我所知,一切都已正确设置。

  • 我已在 Firebase 上创建并链接了该应用
  • 我已经生成并添加了 google plist
  • 我已经用 CocoaPods 安装了库:
    • pod 'Firebase/Core'
    • pod '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

【问题讨论】:

    标签: ios swift firebase firebase-storage


    【解决方案1】:

    看来我调用 Firebase 的时间太早了。我将引用调用移到函数中:

    func uploadToFirebase(data: Data) {
        let ref = FIRStorage.storage().reference(withPath: "images/demoPic.jpg")
       ...
    }
    

    一切都进行得很顺利 - 感谢@mgtla 的提示!

    【讨论】:

      【解决方案2】:

      希望在遵循 Firebase 教程后为其他找到这篇文章的人发布更新。

      applicationDidFinishLaunchingWithOptions 有时可能需要更长的时间才能运行,并且不会在应用程序其他区域(即 ViewController)中的代码运行之前完成运行。

      因此,您可能会收到“尚未配置默认 Firebase 应用”之类的错误消息。或“未找到默认存储分区。您是否正确配置了 Firebase 存储?”因为尚未配置 Firebase 应用

      解决此问题的方法在this answer. 中有详细说明,基本上,您需要将 FirebaseApp.configure() 语句添加到 AppDelegate 中的 override init() 语句,如下所示:

      override init() {
         super.init()
         FIRApp.configure()
         // not really needed unless you really need it FIRDatabase.database().persistenceEnabled = true
      }
      

      希望这会有所帮助!

      【讨论】:

        【解决方案3】:

        这是根 Firebase 存储参考:

        let storageRef = FIRStorage.storage().reference()
        

        【讨论】:

        • 是的。从那里我要去我的路径,等等,但只是让那条线本身导致应用程序崩溃,甚至在任何调用它之前。
        • 你在哪里打电话? @WilliamDelong
        • 我是在课堂上做的...我只是把它放在我的 uploadToFirebase(data: Data) 函数中,似乎可以工作?
        【解决方案4】:

        我在将 Firebase Storage 添加到现有 iOS 应用时遇到了这个问题。

        您需要重新生成GoogleService-Info.plist 文件,该文件现在将正确包含“STORAGE_BUCKET”键,并在您的项目中更新它。

        【讨论】:

          猜你喜欢
          • 2021-04-06
          • 2021-08-25
          • 1970-01-01
          • 2020-01-02
          • 1970-01-01
          • 1970-01-01
          • 2018-03-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多