Everything about iOS app development

Warning: getimagesize(/home/sabminde/public_html/wp-content/uploads failed to open stream: No such file or directory in /home/sabminde/public_html/wp-content/themes/Total/framework/classes/image-resize.php on line 103
Upload Image Firebase Storage Ios Using Swift In Xcode

Upload image to Firebase Storage in iOS using Swift

Post Series: Create an iOS app

Recently I was working on a project that required me to setup Firebase and use it’s database and storage functions in the iOS app.

One interesting feature was, that I didn’t do in a while, was to upload image to Firebase Storage and use that new file url later in my project. So basically, a simple image sharing feature that should be pretty easy right? Well it is.

The preparation itself takes longer than the execution of the feature. You need to setup a new app in Firebase, than copy the configured .plist file to your project, initiate Firebase, and than implement your image upload feature.

Upload image to Firebase Storage

To upload an image to Firebase, you’ll need a few things. First you need to decide how you wish to store your data/images. You can define a simple structure, just like you do it in Finder.

Let’s say you are working with images of cars. You would create a folder: carImages and place all the cars there, right? The same can be achieved in Firebase Storage as well, with one line of code.

As you can see, in this example I put all the images under: carImages folder, and each image will be given a name using the current timestamp.

Constants.Car.imagesFolder is just a simple struct, to make handling constants easier.


The upload part is simple. As you can see, you initialise the storage, a reference – to Firebase Storage – generate a new name for the image, setup the path for that image, and start uploading it using an uploadTask.

Check out my video below that explains a bit better.

Hope you found this tutorial useful, if you did check out my other tutorials and subscribe to my YouTube channel for more videos to come.

Download the project below.

%d bloggers like this: