Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase: Provided bucket does not match the Storage bucket of the current instance in Swift

I have the following code:

let storageRef = FIRStorage().reference(forURL: "gs://slugbug-....appspot.com") // dots intentional
let imageRef = storageRef.child("testImage.jpg")

But the app crashes and I get the following message:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Provided bucket: slugbug-....appspot.com does not match the Storage bucket of the current instance: (null)'

Even if I use

let storageRef = FIRStorage().reference()

The bucket is nil.

Why?

like image 583
Ali Mir Avatar asked Feb 05 '23 09:02

Ali Mir


2 Answers

You are missing .storage().

Check your line. It should be:

let storageRef = FIRStorage.storage().reference(forURL: "gs://slugbug-....appspot.com") // dots intentional

Hope it helps

like image 177
Vlad Pulichev Avatar answered Feb 08 '23 15:02

Vlad Pulichev


I figured out the solution:

I changed the code from:

let storageRef = FIRStorage().reference(forURL: "gs://slugbug-....appspot.com")

to:

let storageRef = FIRStorage.storage().reference(forURL: "gs://slugbug-....appspot.com")

... a very subtle but annoying bug

like image 44
Ali Mir Avatar answered Feb 08 '23 17:02

Ali Mir