Installing Firebase with CocoaPods

Installing Firebase with CocoaPods is much like installing any other pod.

First you’ll need a Podfile. If you’re integrating Firebase into a project that already uses libraries from CocoaPods, obviously you can use the existing file.

Fire up a new terminal window and navigate to the folder where your project is located. Mine is on my desktop in a folder called ‘FirebaseDemo’, so my terminal command will look like this:

Next you can create a new Podfile:

Open that file in a text editor of choice (do not use TextEdit) and you should see something like this

The few instances of ‘FirebaseDemo’ will obviously be replaced with the name of your Xcode project. Lines starting with a hashtag are commented out. I’ll remove them for clarity, you can do the same of leave them as they are.

Replace the line ‘# Pods for FirebaseDemo’  with the following:

As you can see the Firebase library is broken into parts. It’s a substantial library, and you may not need all of it, this gives you flexibility to only include the parts that you want. Including the Core, Database, and Auth component is probably a fairly common setup to get started.

Finally, back in terminal (making sure your still in the correct folder)  run:

CocoaPods will go and install the relevant dependancies you’ll see something like the following:

The important part of this, as with all projects using Cocoapods is that you need to open the .xcworkspace (the white icon) file in Xcode from now on.

Using Firebase in your project requires that you setup a project in the Firebase console and “link” it with an app. For a guide on that process can be found here.