Updating to Swift 4 and Firebase 4
Instagram Firebase
A common recurring pattern with software development is the need to update our codebase to use the latest and greatest SDKs, whether it be the Swift language or 3rd party libraries. You can get away with delaying the migration process for a year or even two years, but you'll be missing out on all the new features and bug fixes available. It's always my recommendation to update Swift and other dependencies as much as possible without disrupting the development cycle. Today we'll be going through how to update our current project to use Swift 4 and Firebase 4 SDKs. Make sure you've properly backed up your project in a separate folder or in Git somewhere before you proceed.

Comments (9)
GeminixClown
5 years ago
Finaly Brian’s return... yeaaaaa
omari
5 years ago
Thanks god he is back. Now please lets finish the Instagram app and also focus on pagination YUHUUU
Adam El-Kadi
5 years ago
Thank you brian, it has finally come to frution
Daryl Wong
5 years ago
Thanks for this update! The part that was difficult to follow in your tutorial was the part on camera. Firebase and all the rest were actually ok even when I was using Swift 4 to go through the tutorials.
Zeff84
5 years ago
This is great Brian, Happy holidays! ;)
stonypig1
5 years ago
happy new year everyone, plus thanks Mr.Brian for this great video
Stephan Dowless
5 years ago
email me at Dowless.stephan@gmail.com for how to do home feed pagination, hashtags/mentions, in app notifications and more!
Akiya Ozawa
5 years ago
Hi, my Sensei Brian and fellow readers! After updating Swfit 4 and Firebase 5, I encountered bugs on signUpController and sharePhotoController, saying "Value of type 'StorageMetadata' has no member 'downloadURL'". because it is deprecated in Firebase 5. I maybe found the solution for this. (not sure if this is right but the app is working) The codes are below: -----signupController.swift--------- @objc func handleSignup() { guard let email = emailTextField.text, email.count > 0 else {return} guard let username = usernameTextField.text, username.count > 0 else {return} guard let password = passwordTextField.text, password.count > 0 else {return} Auth.auth().createUser(withEmail: email, password: password, completion: { (user, error: Error?) in if let err = error { print("failed to create user", err) return } print("successfully create user", user?.user.uid ?? "") guard let image = self.plusPhotoButton.imageView?.image else {return} guard let uploadData = image.jpegData(compressionQuality: 0.3) else {return} let fileName = NSUUID().uuidString Storage.storage().reference().child("profile_images").child(fileName).putData(uploadData, metadata: nil, completion: {(metadata, err) in if let err = err { print("failed to upload profile image:", err) return } Storage.storage().reference().child("profile_images").child(fileName).downloadURL(completion: { (url, err) in if let err = err { print("Failed to get downloadurl", err) return } guard let profileImageURL = url?.absoluteString else {return} print("Successfully uploaded profile image", profileImageURL) guard let uid = user?.user.uid else {return} let disctionaryValues = ["username": username, "profileImagerl": profileImageURL] let values = [uid: disctionaryValues] Database.database().reference().child("users").updateChildValues(values, withCompletionBlock: { (err, ref) in if let err = err { print("failed to save user info into db", err) return } print("Successfully save user info into db") guard let mainTabController = UIApplication.shared.keyWindow?.rootViewController as? MainTabBarController else {return} mainTabController.setupViewControllers() self.dismiss(animated: true, completion: nil) }) }) }) }) } Same logic goes to sharePhotoController.swift file Hope this helps!
Brian Voong
5 years ago
Jeff95
5 years ago
Hello, I just noticed, the comments work fine from the home screen, but if you're to click on the comment bit from the search or profile tab, they don't show up, same for the like, it doesn't work from there do you think it'll be possible to make a quick video to show how to fix that please?
Goldor
4 years ago
You just need to set up the "didTapComment" and "didLike" delegated functions inside of your UserProfileController as well. A simple copy and paste should do it, although refactoring would probably be a better idea, but I didn't take the time to figure it out, since you need access to the controller's posts array.
Jeff95
4 years ago
I’m confused because it already prints out “Trying to show comments”, but doesn’t actually show them. Why is that
HELP & SUPPORT