简体   繁体   English

IOS Swift SwiftUI Firebase “未找到默认存储桶。 您是否正确配置了 Firebase 存储?”

[英]IOS Swift SwiftUI Firebase “No default Storage bucket found. Did you configure Firebase Storage properly?”

When I'm trying to run当我试图跑步时

Text("\(imageURL?.absoluteString ?? "placeholder")")
            
        .onAppear(perform: loadImageFromFirebase)

which should produce a url for my image in Firebase Storage.这应该为我在 Firebase 存储中的图像生成 url。 I get the error "No default Storage bucket found. Did you configure Firebase Storage properly?", and the preview crashes.我收到错误“未找到默认存储桶。您是否正确配置了 Firebase 存储?”,预览崩溃。 The simulator crashes too.模拟器也崩溃了。 I've added我已经添加

override init() {
        super.init()
        FirebaseApp.configure()
    }

to my AppDelegate but this doesn't seem to help.到我的 AppDelegate 但这似乎没有帮助。 This is the function which should fetch the url from Firebase:这是 function 应该从 Firebase 获取 url:

func loadImageFromFirebase() {
        
        let storageRef = Storage.storage().reference(withPath: "Cessna.jpeg")

        storageRef.downloadURL { (url, error) in
            if error != nil {
                print((error?.localizedDescription)!)
                return
            }
            self.imageURL = url!
        }
    }

Nothing seems to help.似乎没有任何帮助。 Some advice would be greatly appreciated.一些建议将不胜感激。

Solved it by disconnecting it from the Firebase project and connecting it again to a new Firebase project.通过将其与 Firebase 项目断开连接并将其再次连接到新的 Firebase 项目来解决此问题。 Also re-downloading the firebase.plist file might have done the trick(make sure when you add the.plist file back to xcode that it doesn't have (2) or (3) at the end of its name. Otherwise xcode won't recognize it.) Also added the 'Firebase/Analytics' pod, not sure how, but this might have helped.还重新下载 firebase.plist 文件可能已经成功(确保当您将 .plist 文件添加回 xcode 时,它的名称末尾没有 (2) 或 (3)。否则 Z8F8EFCE4A06CE9DBED540677CC '不认识它。)还添加了'Firebase/Analytics' pod,不知道如何,但这可能有帮助。 Hope that this is helpful to whomever might be looking for a solution.希望这对可能正在寻找解决方案的人有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM