As always, we'll need to create a new Xcode project.
Create a new Xcode project
Open Xcode and create a new project.
Choose the Single View Application as template. Click next.
Fill out the remaining info for your project. See the example provided below:
Save your Xcode project somewhere you'll be able to easily find later. i.e. ~/Code/
Next we need to integrate Firebase into our project. To do this, we'll use a tool called CocoaPods. This will take care of all the third party libraries we rely on.
What Is a Dependency Manager?
One way of adding third-party code to your project would be to download all of the source code and copy it into your project.
This may sound straightforward, but in reality this approach will fail for many projects. Many third-party libraries come with their own dependencies and very special rules about how they need to be compiled; information that is not in the source files but in the project file of the library.
Even if that approach works, you will have a hard time updating the library. You will have to remove all code and add it again.
To avoid these kinds of problems, software developers have built dependency managers. The most popular one for iOS is CocoaPods.
How Does CocoaPods Work?
CocoaPods provides a huge repository of available iOS libraries. When you want to use CocoaPods you add a special file to your project in which you can list your dependencies. That file is called a Podfile.
If you want to use a library, you need to enter the name (and optionally the version) of the library into your Podfile. Then you can use one of the CocoaPods commands to install the library that you listed in the Podfile.
Creating a Podfile
In the Getting Started section, you should have already installed CocoaPods. If not, make sure to go back and follow the instructions to install CocoaPods.
After installing CocoaPods, we can create a Podfile that will allow us to declare dependencies for our project. The CocoaPods tool provides us with a convenient method to do this:
Open the root directory of your project in a terminal and type:
You can change directories to the root directory of your project by typing cd (make sure you put a space after cd) and then dragging the project folder into Terminal.
Now a Podfile with some skeleton content will be created. Open the Podfile in your favorite text editor. It should look like this:
# Uncomment this line to define a global platform for your project# platform :ios, '9.0'target'Makestagram'do# Comment this line if you're not using Swift and don't want to use dynamic frameworksuse_frameworks!# Pods for Makestagramend
Installing Our Dependencies
Now we are ready to add our dependencies to this file.
Update your Podfile so that it looks like this. Note that we uncommented the platform :ios, '9.0' line. Also pay attention that you're using the correct single quotes.
# Uncomment this line to define a global platform for your projectplatform:ios,'9.0'target'Makestagram'do# Comment this line if you're not using Swift and don't want to use dynamic frameworksuse_frameworks!pod'Firebase/Core'pod'Firebase/Auth'pod'FirebaseUI/Auth'pod'Firebase/Database'pod'Firebase/Storage'end
Then, return to the command line and run:
This step may take some time the first time you run it, up to 10 or 15 minutes.
Now your dependencies will be download and installed.
Verify that you have the correct version of each SDK by running pod update in the root directory of your Makestagram project. The Firebase CocoaPods should be at least 4.0.X.
The next step is very important. After you have installed your first library, CocoaPods will generate an Xcode workspace for you. When using CocoaPods, you need to work with that workspace and no longer with the Xcode project that you have been working with.
Close your Xcode project. Then open the new workspace that CocoaPods has generated:
As discussed earlier, this project contains all the frameworks we need. Additionally it contains a few source code files that we will use later as we progress through the tutorial.
We're now ready to dive into the first step - integrating and connecting our app to Firebase.
We have placed cookies on your device to ensure that we give you the
best experience on our website.
acknowledge that you have read and understand our
Terms of Service. Your use of
Make School’s Products and Services is subject to these policies and terms.