Firebase: Provided Bucket Does Not Match the Storage Bucket of the Current Instance in Swift

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

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

What is a Provided bucket?

As error says config here STORAGE_ROOF_REF

let storageRef = Storage.storage().reference(forURL: Config.STORAGE_ROOF_REF)

should be random2.appspot.com not random.appspot.com , it's better also to make it automatic with

let storageRef = Storage.storage().reference()
storageRef.putData//////

To add a bucket head to firebase console > storage tab then click the right menu ( It contains a billing )

Sample Image

IOS Swift SwiftUI Firebase No default Storage bucket found. Did you configure Firebase Storage properly?

Solved it by disconnecting it from the Firebase project and connecting it again to a new Firebase project. 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. Hope that this is helpful to whomever might be looking for a solution.

Firebase Bucketname Not Available

The documentation for getReferenceFromUrl(String fullUrl) states:

An error is thrown if fullUrl is not associated with the FirebaseApp
used to initialize this FirebaseStorage

Use this code to see the bucket name in your FirebaseApp:

    FirebaseOptions opts = FirebaseApp.getInstance().getOptions();
Log.i(TAG, "Bucket = " + opts.getStorageBucket());

I expect it will not be mooseandroid-a9f96.appspot.com and will instead be the storage_bucket value in the project_info section of your google-services.json file:

  "project_info": {
"project_number": "816275527980",
"firebase_url": "https://project-8693710910123456789.firebaseio.com",
"project_id": "project-8693710910123456789",
"storage_bucket": "project-8693710910123456789.appspot.com"
},

Download and use files stored in Firebase Storage from different projects

I tried that once and it lead to an unhappy time. In my case I had two different buckets for my images, so I had to find an alternate solution.

If you have only a single bucket, you can try configuring that bucket in your FIRApp:

let firOptions = FIROptions(googleAppID: googleAppID, bundleID: bundleID, GCMSenderID: GCMSenderID, APIKey: nil, clientID: nil, trackingID: nil, androidClientID: nil, databaseURL: databaseURL, storageBucket: storageBucket, deepLinkURLScheme: nil)        
FIRApp.configureWithName("anotherClient", options: options)
let app = FIRApp(named: "anotherClient")

let storageRef = FIRStorage.storage(app: app!).reference()

Taken from this answer, so you may need to modify it to suit your needs

With that app, you can then use the Firebase Storage API as you're already doing to download the image data.

If you have multiple buckets (as I had), you either have to configure multiple apps or (as I did) handle downloading the image from the downloadURL yourself (without using the Firebase Storage API):

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0)) {
let data = NSData(contentsOfURL: downloadURL) //make sure your image in this url does exist, otherwise unwrap in a if let check
dispatch_async(dispatch_get_main_queue(), {
let downloadedImage = UIImage(data: data!)
});
}

Error after adding FirebaseFireStoreSwift-Beta with Swift Package Manager

Many apologies, the issue was introduced by me.

It appears that symbol resolution has changed slightly in Swift between Xcode 12.4 and Xcode 13.

I have made a PR that fixes the compilation issue on Xcode 12.4 here:
https://github.com/firebase/firebase-ios-sdk/pull/9438

Until then, if possible, you can update to the latest version of Xcode.
If that is not possible, then if you use a package manager where you can make local edits, you can rename the variable data to something else (like d) to make it compile.

If you can't do that, then a more substantial workaround would be to fork the repository, check out the release tag, create a new branch and fix the error, then pointing your package manager to you own branch including the fix.

Another solution is of course to stay on 8.12 of Firebase until the PR above is merged and released.



Related Topics



Leave a reply



Submit