Start course
2h 13m

In this course, we're going to create a Snapchat clone using structs and various advanced techniques of Firestore.

Learning Objectives

  • Learn how to make a Snapchat clone
  • Understand all the features of Snapchat and how to set them up

Intended Audience

This course is intended for anyone who wants to learn how to develop apps on iOS.


To get the most out of this course, some basic knowledge of iOS development would be beneficial. We recommend that you take this course as part of the Developing Mobile Apps for iOS learning path.


Hi, within this lecture, we're going to finish our authentication process by implementing remember user and log out functions. Right now if I run this from scratch, it will ask me one more time to sign in and that's not what we want. So, in order to take care of that, we're going to use what we have been using so far. We're going to come over here to our Tab Bar and we're going to give some Storyboard ID to our Tab Bar, okay? So, this will be tabBar and make sure that you don't have any class over here. So, this is just a UITabBarController, okay? And let's come to our SceneDelegate.swift where we have the window variable. And under this function, we'll connect to session function. I'm going to check to see if we have the user or not. So, I'm going to import the Firebase, okay? And over here we're going to see if the current user is nil. So, I'm going to create the current user from authentication module and I'm going to check to see if this user is not nil. So, if currentUser != nil, then it means that I have a user signed in already. So, I can use that user, right? So, let me create my main.storyboard. So, this will be a Storyboard and this will ask me for a name and a bundle and name will be main, bundle will be nil and then I'm going to create my tabBar as a variable and then I'm going to say board.instantiateViewController, okay? So, this will ask me for an identifier and this is the identifier that I have just given. So, this is tab bar. So, I'm going to first cast this as a UITabBarController, okay? So, UITabBarController, this one, and if this holds, then I'm going to make my rootViewController = tabBar. So, if we have a logged in user, we're going to use our tabBar as it's rootViewController so we're going to take the users to the feedViewController. Now let's run this in our simulator and let's see if we can go to with FeedVC.swift directly because we have already signed in with James, right? So, there is no reason to see sign in View Controller right now and here we go, we are inside. Now we have to take care of this log out functionality as well so that we can try our functions. So, let's come over here to log out. Of course, we're going to have to have a segue from our log out Settings View Controller to Sign in View Controller. So, let me do a present modally segue and then later on I'm going to click on this and go to do inspector over here to make a full screen segue and I'm going to call this toSignInVC. So, let me copy this because we're going to need it later on and let me go over to my Settings View Controller. Over here, we're going to have to do a do try catch because remember the logout function kind of throws an error. So, let's do that. Let me import the Firebase first, okay, and then I'm going to say do an open parenthesis, I'm going to try over here and then later on I'm going to catch if there is any error. So, what I'm about to do is to logout from the current user. So, I'm going to do that with auth of course. So, Auth.auth.signOut. And as you can see this throws an error, so that's why we are doing this do try catch. After doing that, of course, I'm going to perform a segue. So, let me say self.performSegue and we're going to pass in the value that we have copied and here you go. Now we are ready to test this. So, let's run our simulator and let's go to our Settings View Controller, okay, so let's go to Settings View Controller and logout and over here let me run this from beginning and we're going to see if we have any problem; here you go. Now we are in the Sign In View Controller. Let me sign in with James and we're going to see, here we are. We are inside and if we run this from beginning, if we go to FeedVC.swift as we are now, now it means that it's completed. We are done with our authentication process. Now we are ready to take care of this upload View Controller so that we can upload some snaps to the Firebase server. That's what we're going to do within the next lecture.


About the Author
Learning Paths

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.

Covered Topics