Hey Hey everybody welcome to the next video.
And in this video what we're going to do is we're going to set up firebase with our project firebase.
As you might know is a really really cool.
Real time back end server that's going to let us do authentication is going to let us log in users.
It's going to let Us store things in our database like chat messages and different types of information.
So let's go ahead and get started creating a firebase project and downloading it into our X code project.
So go ahead and open up a Safari window and you're actually going to want to go to firebase dot Google
dot com.
This is the site you'll see and you're going to need to log into your Google account like I did and
then click go to console and when you do that you'll see this window.
Now I have a bunch of other projects here from other courses and other things that I've done this break
point project is from the one that I used when building my app the first time.
But we're going to create a new one I'm going to show you all the way from the beginning to the end.
So go ahead and click add project.
Now we're going to give it a name.
I'm going to call this break point.
I already have one called Break point so let's just call this one breakpoint dev.
Choose your country or region for me it's the United States and then click Create project.
Now as this is loading basically what we're going to do is we're going to configure this so that firebase
can talk to our application and we're basically going to sync them together using a P list file that
we're going to generate but it's actually going to need some information from our X could project.
So go ahead and pull that open and let's just keep it in the background.
Now this is the firebase con. It's very cool.
On the left you can see authentication database storage hosting cetera et cetera.
There's lots of things you can do here and I really encourage you to go through and read more because
there's a lot that firebase can do and for free too which is cool.
There of course are limitations but free is a pretty good price for what it what you get.
So let's go ahead and let's add this firebase project to our X code project to do that.
Go ahead and click iOS and this is going to take us through the iOS QuickStart.
Now it begins by telling us to register our app and it's asking for our bundle I.D. If you remember
a few videos back I told you to now if you remember a few videos back I told you that you'd be needing
your bundle I.D. And this is where you will use it haha.
So open up X code and go to your project settings and find your bundle identifier that bundle ID copy
it and then head back over to Safari.
We're going to paste that in here and this basically gives firebase a way to communicate with your application.
Now of course we can give the app a nickname.
I'm just going to call it break point but it is completely optional and up to you.
Once you've done that go ahead and click register app and then it's going to generate a configuration
file for you to download.
Now it gives you some great instructions here to drag it into your project and make sure that you add
it to all of the targets.
We'll do that.
So go ahead and let's download that file and you'll see that it will download to my downloads.
But the issue is that I have downloaded this before and it's basically renamed it to Google service
info Doppie list so I'm going to actually put it on my desktop here and I'm going to just rename it
Google service dash info so that I don't have that dash 2 at the end because otherwise my app won't
know what to do with it.
OK.
So we have downloaded it.
Now we just need to drag it into our X code project.
So I'm going to switch over to that.
And now all we need to do is simply drag and drop.
OK.
Just like firebase said make sure that you add it to the target appropriately and click Finish.
Now if you look in here this contains all of the important information that we need.
Like our project id or storage bucket.
All this special information that we need including our database you are l there's a lot of good stuff
in here that firebase just does for us.
It's that easy.
Very very cool.
So now we're going to go ahead and install something called a cocoa pod and a cocoa pod is basically
a really easy way for you to bring in third party code into your app and give it extra functionality
and extra frameworks and libraries to work with firebase is one of those.
So to do that we're going to go ahead and actually open up a terminal window just like so.
And we're also going to find our project.
OK so there's the breakpoint project.
Now if we look at the firebase directions here it will it tells us we need to create a pod file using
POD in it then we need to open our pod file and add pod firebase core.
Then it says we need to save the file and run spot install.
So that's what we're going to do.
Go ahead and minimize that window minimize everything.
And what we're going to do is we're going to change directories into our breakpoint project folder.
So go ahead and type CD and then drag in your breakpoint project folder.
That's that's what I like to do instead of having to type out all of this madness.
I just like to type CD space and then drag the folder onto the terminal.
OK.
So after that go ahead and press enter.
And now we have entered the break point project library or project folder rather.
So what we're going to do.
Like it's said was first to go ahead and type pod in it.
When we press Enter you'll notice that it will initialize an empty pod file in our folder.
Very cool.
If you get an error that means that you have not yet installed cocoa pods and so in order to do that
you need to type sudo gem.
Gem install cocoa pots.
Press Enter let it do its thing.
Enter your password and you'll have crockpots very easy.
But assuming you already have cocoa pods installed you need to start by typing pod in it.
And now we have a POD file.
So go ahead and right click on the pod file and we're going to open it with Adam.
This is a text editor that I really like to use.
I advise against using text at it and I'll tell you that later in another section of this course but
on text that it sometimes has problems with formatting so I like to use ADOM and it's totally free and
available online.
So open Adam and it's going to show us our pod file.
Ok this is what it looks like.
And you'll notice down here it says pods for breakpoint.
OK this is where we are going to add the pods and let's go look back at safari to see what firebase
asked us to do.
It told us to add pod firebase core case.
That is where we are going to.
That's what we're going to put here.
So to do that type pod firebase slash core.
But you know what.
That's actually not going to be enough for what we need to do.
So we're also going to include authentication and database so to do that.
Go ahead and type pod firebase slash database and POD firebase slash off OK.
And that's going to give us authentication capabilities as well as the ability to access the database
firebase core doesn't come with that by standard.
So once you have added those three cocoa pods go ahead and save and close out of them.
Quit it and then the last step is just to run Podd install that's going to go ahead and create an X-Sea
workspace for us and it'll let us use firebase on our app.
Really really cool.
So let's go ahead and head back into the terminal window.
And I want to show you what happens in the Finder when we run pod install.
OK.
Once you've typed that press enter and you'll notice it'll start to download.
All of these tools now.
These ones were not actually all of these and analytics we didn't include those in our pod file but
they are kind of extra extensions that are required by them so it automatically downloads them for us
which is pretty cool actually.
OK.
So now that we've installed are pods we have an X C workspace from now on in the course do not open
your X could project only open the white and blue.
Sorry the mostly white X-C workspace icon.
That's what we got to open if we want to use our cocoa pots.
All right cool.
So now that that's done close the terminal window and you know what I think our ex-coach project is
still open.
So I'm actually going to close it and then reopen it using X-C workspace.
So double click and let's see what we have.
OK very cool.
We have break breakpoint the application and we have a POD project that contains all of the cocoa pods
that we just installed.
So let's go ahead and let's set up our project so that we can actually communicate from our ex-cult
project to firebase because right now we have linked firebase to our project.
Right.
We have set it up so that the cocoa pod is installed.
We've downloaded the configuration file but now we need to enable the execute project to talk back up
to the firebase project online.
To do that we need to add some initialization code in our app delegate.
OK.
Really really easy.
We just need to go into app delegate that swift and type firebase app doc configure.
It's that easy.
So do that now by opening app delegate then right here in.
Did finish launching with options before we returned TRUE.
We're going to go ahead and type Oh sorry first this is an important thing when you're using a cocoa
pod if you want access to it you need to import it just like you would import any other framework on
iOS So we're going to import firebase.
And now we can go ahead and access firebase app that configure just like it said online and you know
what boom we're done.
We are connected.
We can access everything from firebase.
Now we haven't yet written the code to do that but we are now at this point totally connected.
Let's go ahead and build the project by doing a command B.
Make sure everything loads and everything is good to go.
Let's see.
Are we good.
Boom build succeeded we are good to go.
So our project is now successfully connected to firebase and we're good to start setting up our data
service to start pushing information to our server on firebase so exciting.
Let's go ahead and move over to the next video and let's get started with that right now.