0

I'm using:

  • iOS - Swift 4
  • Cocoapods 1.4.0
  • Firebase (5.4.0)
  • FirebaseCore (5.0.5)
  • FirebaseStorage (3.0.0)

When I'm running the attached code, my app crashing with signal SIGABRT error at the AppDelegate class and prints libc++abi.dylib: terminating with uncaught exception of type NSException in the console.

I'v tried to run some debugging and what I found is that the problem occurred in the imageReference.delete{ (error) in } method.

*Note that it didn't enter to the block at all, it failed in the method itself and because of that the image is not deleting from Firebase console when I'm calling to the delete method.

My code:

func deleteImage(for url:String){
    print(url) // https://firebasestorage.googleapis.com/v0/b/my-app.appspot.com/o/itemsImages%2F225121501531684886976.jpg?alt=media&token=token
    let imageReference = Storage.storage().reference(forURL: url)
    imageReference.delete { (error) in // Fails here with: libc++abi.dylib: terminating with uncaught exception of type NSException
        print("completion") // Not getting to this point
        if let error = error{
            print(error)
        }
    }
}

Edit:

After very deep digging I'v understand that my problem is that I'm calling this method via closure at some point of the "events' tree" (I'm calling some function that calling to another function that calling to the delete method from closure) and thats what cause the problem.

Now the question is how can I call it via this closure without make this error? (I can't call it outside of it)

Ido
  • 473
  • 4
  • 16
  • I would like to help, but I need more information. When you go to the Firebase Console, do you see that the image is deleted from Cloud Storage, or does it still exist? What is the entire error that you're seeing, rather than just the end of it? If I had to guess without additional info, I'd say that somewhere else in the code is still referencing that image, and when it disappears, an optional is unwrapped with a nil value. – Jen Person Jul 17 '18 at 17:29
  • Thanks for you'r answer, The images are **not** deleting from Firebase console when I'm calling the `delete` function. Thats the problem, this is the entire error, if it was saying any additional information it would help me to try things that related to the specific problem... – Ido Jul 17 '18 at 22:48
  • If I didn't mentioned it yet, my cocoapods version is 1.4.0, I had to downgrade it from 1.5.2 because of some bugs, maybe this is what cause this crash? Can you suggest my specific version for Firebase pod to try with this version of cocoapods? – Ido Jul 18 '18 at 10:55
  • It's pretty unlikely that's the entire error--that's usually what's written at the end of the error. If you scroll up in the terminal, it should have more information. – Jen Person Jul 18 '18 at 14:49
  • I wish it was tell me more then that, but this is all I get in the console :( I'v also tried to use `Fabric Crashlytics` and it didn't catch any error... – Ido Jul 18 '18 at 15:06
  • I'v understand that my problem is that I'm calling this method via closure at some point of the "events' tree" and thats what cause the problem, but now the question is how can I call it via this closure without make this error? (I can't call it outside of it) – Ido Jul 19 '18 at 20:28

2 Answers2

0

I'd start by asking if you have a strong reference to that image somewhere else ? Or is the image being used in a UIImage Control?

  • Sorry, I didn't got what you'r trying to say. I'm saving the image's download url in my database and when the user want to delete it I'm using the saved url with `Storage.storage().reference(forURL: url)` – Ido Jul 17 '18 at 23:02
  • Oh, now I got it, but no, I don't have any strong reference to the image itself, I have ref only for the url (as string). – Ido Jul 17 '18 at 23:09
  • If I didn't mentioned it yet, my cocoapods version is 1.4.0, I had to downgrade it from 1.5.2 because of some bugs, maybe this is what cause this crash? Can you suggest my specific version for Firebase pod to try with this version of cocoapods? – Ido Jul 18 '18 at 10:57
  • Please try to access the url from the browser. May be You are missing a forward slash (/) in the url ? after items: https://firebasestorage.googleapis.com/v0/b/my-app.appspot.com/o/itemsImages%2F225121501531684886976.jpg?alt=media&token=token – ravi chandra Jul 18 '18 at 23:59
  • I'v understand that my problem is that I'm calling this method via closure at some point of the "events' tree" and thats what cause the problem, but now the question is how can I call it via this closure without make this error? (I can't call it outside of it) – Ido Jul 19 '18 at 20:28
0

At the end the problem was with the UITableView itself and not with Firebase.

I didn't update the UITableView's data array correctly and that produced this crashing. I wasn't aware of it because the errors in xCode's console were disabled from some reason (Those answeres helped me to enable it back: #1, #2).

Hope anyone else that will face with wired error like that (without enabled error logs, of course) will be able to use my unpleasant experience and find the solution faster and easier.

Ido
  • 473
  • 4
  • 16