In this course, we're going to create an Instagram Clone and learn how to work with cloud servers using Firebase. By the end of this course, you will be well-equipped to build your own apps!
This course is designed for anyone who wants to:
- Learn about iOS development and coding
- Move into a career as an iOS developer
- Master Swift skills
To get the most out of this course, you should have some basic knowledge of iOS.
Hi. Within this lecture, we're going to see how we can connect this Firebase project with our Xcode project, okay? In order to do that, I'm going to go for iOS here. By the way, they can change these images, they can change the layouts from here, and you're just going to have to find the iOS icon and click on it. That's all you have to do, okay? And after that, it will ask you for your iOS bundle ID. So, this is the bundle ID of the project that you want to connect your Firebase, okay? So, this is going to register our app and it asks for a unique ID like a bundle ID in order to connect the two projects together. So, remember if you click on this, you can see your bundle identifier and you can copy it and then paste it here so that it will be registered to your bundle ID. So, if you want, you can give this app a nickname, so I'm going to go for the InstaCloneFirebase one more time and it's optional, you don't have to do that. And later on, it will ask for an app store ID. Since we haven't put our project in the app store yet, we can just skip this and say register the app. So, this will be registered and then it will create a configuration file for us. So, now you'll see the configuration file and this is called a GoogleService-info.plist. All we have to do is just downloading this file and add this to our project, okay? So, let me click on here download GoogleService-info.plist. And if there is any bug or something, if this doesn't work, you can always come back later on to download it from the settings of your project, okay? Let me drag and drop in here and make sure that you drag and drop inside of your InstaCloneFirebase folder and make sure that these copy items if needed and target is selected, and you can just click on 'Finish' to import this file. As you can see, if you click on it, we have some credentials here and we have some API keys, client IDs and other some important stuff in order to connect our service, connect our Firebase server. So, these values are actually just for us. They're created uniquely for our project. So, if you don't have this GoogleService.info or if you have a bad GoogleService.info file, your app won't connect to the Firebase, so make sure you do this step. And then later on you have to add Firebase SDKs so there is a guide to do that, okay? So, I'm going to click on that guide and it will take me back to our dashboard. So, in here in the documentation, we're going to have to find how to download, how to integrateFirebase software development kits to our Xcode project. And as you can see, there're documentation for iOS, android, Flutter, and Web, so we're going to go for iOS obviously, and we have a very good documentation in here. Later on, we're going to see the Cloud Firestore, Authentication, Storage and they're explaining everything we need to know actually. In fact, you could have just come over here and try to understand everything by reading from this documentation, but don't worry, I'm going to explain everything. So, right now we have to come up with a way to integrate SDKs. If you follow here, you will see some steps like create a project, register your app. We have already done this, right? We have created an Xcode project, we have registered our app using our bundle app ID, and we even have integrated this config file. The step 4 would be to add the Firebase SDKs. So, that's what we're looking for. So, let's see how it's done. As you can see there are steps in here as well and it asks us to create something called Podfile, and it says that you have to run this command, pod init. So, what is a pod? So, it's kind of a tool, it's kind of a technology that lets us integrate this kind of SDKs external libraries into our code. So, whenever we deal with this kind of external libraries, the code that is written by other people that we want to integrate in our project, we're going to use pods. And in order to do that, we're going to learn something called Cocoapods. It's a tool to utilize pods easily because we have to have this in our computer in order to work with pods so that we can easily integrate every project in our own project. And this is not only valid for Firebase as well, we're going to use this a lot in other libraries from now on. So, we have to just deal with this pod and then we have to call this vom line like FirebaseApp.configure. And I'm showing you all this documentation, I can easily come and do this on my own and show you how it's done, but I suggest you follow the documentation as well so that you get the habit of following documentation because you're going to be working with other libraries later on when you're an iOS developer than what we have seen in the course. So, here we have something called CocoaPods as I say. So, the web address is cocoapods.org. If you come to this website, you will see how to install CocoaPods on your computer on your MacOS. So, here we see a command. And remember we have used Terminal before. So, that's what we're going to use in this lecture as well. We're going to use Terminal to run this install cocoapods command, and we're going to use Terminal to initialize pods and integrate everything. So, make sure you close your Xcode project because we will be integrating some new files to it, and then search for Terminal as we have done before. All you have to do is just press 'Command' and space on your keyboard and hit Terminal. And we have seen how to use this Terminal right in the Git section. So, if you have skipped it, I really suggest you go back and watch it so that you know how to work with Terminal, but I'm going to explain the basics one more time in case you missed it and if you don't want to go back but I'm going to do this fast, okay? So, this is a Terminal and if you write a command here like clear, it gets executed as long as it makes sense, of course. And in order to work, in order to make these cocoapods work in our computer, we have to download it. And it asks us to run this command, sudo game, install cocoapods. If you write this and hit 'Enter', it will download the cocoapods for you. It will ask you for your password, this is your Mac password, you type it and it will show as if it's not writing but it's for security. If you write it and hit 'Enter', it will accept it and it will just start downloading the CocoaPods in your computer. So, this is kind of going fast for me, but it was already installed on my computer, so I believe it just got updated. Maybe it will take a little bit time for you. And this command goes like this, sudo game install cocoapods, and this is the command that we use actually to install repositories in our Mac. Like if I want to add something else, I could have said sudo game install something else. Okay, since now we have the CocoaPods, we can actually initialize the Podfile and download the Firebase SDKs to our computer. So, let me clear the screen and go back to our Firebase documentation, okay? We are done with the CocoaPods right now. It says that you have to cd in your project directory. And what is a cd? We have seen it before. It stands for change directory. So, we can go from one directory to another and we can see the content of that folder and we can initialize a pod and we can write whatever we want inside of that pod, and then we can run this pod install command to install these pods in our current folder. So, let's do that. Remember if we run ls or cd, we can go back and forth between the folders and file system. For example, if I write ls, it will show me the available content inside of that folder. For example, I want to go to Downloads folder because that's where my iOS Complete folder is. So, I'm going to write cd Downloads. And now I'm inside the Downloads. So, now if I say ls, I will just see the downloads contents. And remember if you want to go to desktop, for instance, you have to write Desktop with a capitalized D as you see it in here. So, if I say ls, if I open my Downloads you will see these contents. As you can see, if I open my Downloads folder, These are the real contents that I see in my Downloads folder. So, I want to go to this iOS Complete folder. So, if I write iOS and hit 'Tab', it will auto complete it for me because for spaces we have some extra special syntax in here as a reverse slash. I can just hit 'Tab' and it will auto complete it for me. Now I'm inside of iOS Complete. Now, if I say less, I will see all of these files and folders, but I just want to go to InstaCloneFirebase. If I write int and hit 'Tab', it will auto complete it for me. And now I clicked here, I'm inside of this folder, and this is where I want to actually run this pod init command. And remember, we have to say pod init. It will initialize a Podfile for us so that we can edit this file and we can download whatever we want. So, if you run this pod init, then let me go back to here one more time. Let me go back to iOS Complete InstaCloneFirebase. Now, as you can see, we have the Podfile, okay? We can actually open this file right now and edit it in a way that we want. In order to do that, I'm going to right click and say 'Open With TextEdit', okay? So, this is our default Podfile. So, let me zoom in a little bit so we can see it better, okay? So, let me make this a little bit bigger. Yes, this is what we want. After use frameworks line, hit some entries, so we will have some place. That is where I want to copy and paste the SDK names, pod names. So, here, for example, it asks us to import Firebase Analytics. I'm going to copy and paste it in here. So, whatever I want to download, I'm going to paste in this Podfile. And this is not the only module that I want to go ahead and get. Why? Because Firebase actually provides modules in a separate pods. For example, we will have a pod for Firestore, for Storage, for Authentication. Why would they do that? Why does it even bother to provide us with different pods? Because maybe we're going to use only Authentication feature of Firebase in our app. We're not going to use the Firestore, we're not going to use Storage. So, we don't want to make our app too big, so that in a very logical way, they just provide us with different pods so that we can get whatever we want. We shouldn't get everything in the Firebase in order to limit our app size. So, if you go to Authentication and iOS, you can say get started or you can just click on the first line here, and you're going to find the necessary pods in order to integrate Firebase Authentication in our project. We have already got Analytics, so I'm going to go for Auth. And in the Firestore as well, if you come over here to Introduction and Get started and not the Realtime Database, by the way. We're going to go for Firestore. I'm going to explain the difference between them, but for right now just know that Firestore is Neeva. So, Firestore is the hardest technology available. Realtime databases is all new, so we're going to go for Firestore. So, let me copy these pods and paste it in my project here. So, we are downloading Core and Firestore. And then the last thing that we want to get is the Storage, okay? So, let's click on 'Get started' and see if we can get this. Yes, we already have analytics, so I'm going to go for Storage. And that's it; that's all I want to get. Firebase Analytics, Auth, Core, Firestore, and Storage. So, let me close this after saving, okay? So, let me go back to my original documentation here by clicking on the 'Back' button. So, let me hit 'Tab'. So, this is what we want to run next. So, we have to run pod install. Make sure that you save and close the Podfile, make sure your Xcode is closed and write pod install and hit 'Enter'. So, this will download these dependencies, these SDKs one by one, and we will need to do that just once. By the way, we're going to do that once and then we can go back to our Xcode project so that we can work on it every time we open the project. And this is going to take some time by the way because Firebase is big, and we're going to be downloading five modules. So, feel free to pause the video and come back when you're done. So, when you download the dependency for the first time, it will show its line in green. So, as you can see, we're seeing this in green and we're seeing the others in green when they're done. So, we are seeing everything in green. If I run pod install one more time, they will be all in black, okay? So, these are all integrated in my Xcode project right now. We are done with this terminal. So, I'm going to close this and I'm going to come back to my iOS folder. So, in InstaCloneFirebase here, now we have two files. We are going to use this workspace rather than the Xcode project. So, what is the difference between those two? So, X workspace actually contains both the project and the parts. So, make sure you open the workspace. If you open the project from now on, it won't work. So, make sure you select the right file so we won't have a problem in here. So, let me make this into a full screen so that we can see what's in the left hand pane. As you can see, we still have the View Controller and the old files that we used to have every time. But we also have the pods here as well. So, if you open these frameworks, if you open the files and folders, you're going to see these are the files, these are the Firebase project that we have downloaded, so we can use it in our app. So, that's all for integrating Firebase in our app. We're going to have to do a little bit of configuration. We're going to do them in the next lecture.
Atil is an instructor at Bogazici University, where he graduated back in 2010. He is also co-founder of Academy Club, which provides training, and Pera Games, which operates in the mobile gaming industry.