Build a SwiftUI chat app with Firestore from scratch

  Переглядів 51,200

DesignCode

DesignCode

День тому

💬 Build a chat application with real-time updates from scratch in SwiftUI, with Firebase Firestore
In this tutorial, you'll learn how to code all the components required that make up the chat view, create and configure a Firebase project, connect Firebase to the app, and read from and write to Firestore, with real-time updates - meaning the chat conversation will be updated instantly when a new message is added to Firestore.
🔗 Links mentioned in the video:
➡ Unsplash: unsplash.com/
➡ Firebase Console: console.firebase.google.com/
➡ Firebase iOS SDK Github repo: github.com/firebase/firebase-...
➡ Cloud Firestore Data model: firebase.google.com/docs/fire...
➡ Get to know Firestore UKposts video: • What is a NoSQL Databa...
➡ ScrollViewReader documentation: developer.apple.com/documenta...
➡ scrollTo(_:anchor:) documentation: developer.apple.com/documenta...)
👩🏻‍💻 Source code on Github:
➡ github.com/stephdiep/ChatApp
✏️ Watch without ads, and access the written version and source files:
➡ Part 1: designcode.io/quick-apps-swif...
➡ Part 2: designcode.io/quick-apps-swif...
➡ Part 3: designcode.io/quick-apps-swif...
🪄 Join our channel and unlock members-only perks:
➡ / @designcodeteam
👋🏻 Let's connect!
➡ Twitter: / diepsteph
🎞 Video timestamps
➡ Part 1 - Create project, components and model
0:00 - Introduction
1:40 - Create Xcode project
2:51 - Update Assets folder
4:34 - Code the TitleRow
9:03 - Create the Message model
10:31 - Code the MessageBubble
➡ Part 2 - Finish UI and configure Firebase
18:34 - Code the MessageField
23:24 - Create Firebase project
26:01 - Add Firebase SDK and initialization code
28:29 - Create Firestore database
29:34 - Add data to Firestore
➡ Part 3 - Read and write with Firestore
32:07 - Call the data with real-time updates
40:13 - Writing to Firestore
43:42 - Scroll to last message
48:04 - Conclusion
#firebase #firestore #chat #app #tutorial

КОМЕНТАРІ: 66
@enriqueavina6827
@enriqueavina6827 Рік тому
Your tutorial has been so incredibly helpful for a new Swift developer. Thank you so much! So concise!
@rendem8168
@rendem8168 Рік тому
You’ve made it look so easy, this is something I can actually try and recreate. You showed where everything is coming from. I hope you have a part 2 for the receiver to message back and also to have a group chat.
@vebbis5961
@vebbis5961 2 роки тому
The design on the view for the chat is amaizing
@happyfox3275
@happyfox3275 2 роки тому
Great tutorial, you explain everything very good!
@thattim
@thattim 2 роки тому
Thank you so much Stephanie!
@manmathanmary8564
@manmathanmary8564 8 місяців тому
As you mentioned, it's really fun learning. thanks !
@carmineloschiavo5864
@carmineloschiavo5864 2 роки тому
Stephanie as usual you did a great job 😃. I am still fairly new to app development but this is really helping me out! I can’t wait for the next app to try. 📱💝💻
@ID_Station
@ID_Station Рік тому
Oh my girl is back with another video that we can actually take and turn into our own thing. Amazing
@g43s
@g43s 2 роки тому
Nice video! id love a second part where you could add users and enable recieving messages and authentication
@paschal4
@paschal4 2 роки тому
Excellent tutorial 👊👊 keep up the 👍 work
@AllanZhang16
@AllanZhang16 Рік тому
What a great video. Super helpful and really well explained.
@PORKII-lw9um
@PORKII-lw9um Рік тому
Well done. Thank you so much.
@carterhawkins3034
@carterhawkins3034 Рік тому
I loved how simple the tutorial is. I just have a quick question. How could you delete messages and also edit the messages?
@pat_trudel
@pat_trudel 2 роки тому
Love this channel, great videos I am advanced in UIKit but enjoy these videos to learn more about SwiftUI Keep it up! (Also from Montreal 🇨🇦)
@DesignCodeTeam
@DesignCodeTeam 2 роки тому
Glad they’re helpful! Hello from Montreal!
@30guarino
@30guarino 7 місяців тому
@@DesignCodeTeam ask Stephanie why she didn't use the keyboard on the simulator for viewers to see the messages animate up .....something tells me because it wouldn't work and that's why it was added in Firestore manually
@muratkul7377
@muratkul7377 Рік тому
Good tutorial and I have learned quite a few things, thank you. On the other hand this is only the half of the story, you could go ahead and show a list of messages, how to manage 'received' in real life (cause what happens when the other person recieves the message), how to stop listening the snapshot and create a new listener for another chat etc...
@markfrancisco1997
@markfrancisco1997 Рік тому
This girl is on fire! Amazing, well done. Can tell how super smart this girl is!
@DmitryKanunnikoff
@DmitryKanunnikoff 2 роки тому
Excellent! Thank you very much!
@DesignCodeTeam
@DesignCodeTeam 2 роки тому
You are welcome!
@ociellerma8953
@ociellerma8953 2 роки тому
Great Video! Thank you.
@norcrowe
@norcrowe 2 роки тому
Thank U So Much!
@monnydhingra6369
@monnydhingra6369 Рік тому
Your tutorial video is excellent...
@joelsoo5354
@joelsoo5354 Рік тому
Great tutorial! May I ask how to load the history message bubbles to the top of the page?
@tridaynee
@tridaynee 2 роки тому
amazing good job bro
@TechTokeMaster
@TechTokeMaster Місяць тому
You're amazing!
@karandeepsingh1898
@karandeepsingh1898 Рік тому
AWESOME EXPERIENCE
@codejunkie6300
@codejunkie6300 2 роки тому
Easiest tutorial I've seen on this topic. The next logical step would be a tutorial on how to add users and text specific users...please.
@DesignCodeTeam
@DesignCodeTeam 2 роки тому
Hi! For that, I suggest you to change the structure of your Firestore database a bit. First, create a collection called "users" and, under each user, you'll have another collection called "messages". This way, the messages will be saved under the corresponding user and you'll be able to map through the users and their specific messages. Hope this helps! - Stephanie
@ethan4807
@ethan4807 7 місяців тому
thank you
@keattisakmunfc3449
@keattisakmunfc3449 3 місяці тому
very cool thank you
@user-hf8hk8et6g
@user-hf8hk8et6g 2 роки тому
Hello ! Thank you for showing me a good tutorial! I'm studying iOS, so can I use it as a job portfolio while watching videos and creating applications?
@DesignCodeTeam
@DesignCodeTeam 2 роки тому
Hi! Sure, you can totally add the app you create out of this tutorial in your job portfolio! Good luck in your job hunt! 💪🏻 - Stephanie
@FabricioMTL
@FabricioMTL Рік тому
Hey Stephanie do you I have PDF of the course or web link of it and thank you for teaching us how to code. You have all my ❤️
@ESquirez
@ESquirez 2 роки тому
Brilliant, this was exactly what I was looking for
@DesignCodeTeam
@DesignCodeTeam 2 роки тому
Glad it's helpful!
@ESquirez
@ESquirez 2 роки тому
@@DesignCodeTeam hi, it was super helpful. I have one question, how would I go about creating different chat rooms via swiftUI?
@DesignCodeTeam
@DesignCodeTeam 2 роки тому
Hi Emmanuel, I'd suggest you to create a collection in Firestore called "chatrooms" and, under each chatroom, create a "messages" collection. That way, you can iterate over the chatrooms in your SwiftUI app and, for each chat, display the corresponding messages. - Stephanie
@ESquirez
@ESquirez 2 роки тому
@@DesignCodeTeam hi Thanks for this. I really appreciate 😃
@stephaniewagstaff6563
@stephaniewagstaff6563 2 роки тому
I have been trying to learn SwiftUi for almost 2 years self taught. I come from no background in this field, I am an interior designer by trade but I have a dream. I have been close to giving up on myself after Covid took a part of my brain… I have been stumbling trying to find the next lesson but I pray and have faith. You know the odds of finding a female programmer…. And then one with this same name?? I’m energized to start this journey with you today and am so glad you put it out there. I’m naive in so many ways, for instance if I have a ? Do I put it here for everyone to see? I haven’t really used UKposts ( I know that’s crazy…I’m 50 lol).
@juliancowell891
@juliancowell891 Рік тому
Please never give up. I think sometimes videos can be difficult to learn from. It might be useful to find written resources as well to supplement UKposts tutorials.
@tarun_reddy
@tarun_reddy 2 роки тому
Do we need to be aware of the addSnapListener and turn it off when we’re not using it? Ive read some people stressing that.
@juliapp2528
@juliapp2528 2 роки тому
hey, i'm getting the error in the catch block and I cant figure out why? I have everything set up right. do you know what could possibly throw that error? Thanks
@zenki9862
@zenki9862 7 місяців тому
Is there any performance concerns? The message array is sorted every time when there’s an update from the firebase. The demo is using a scroll view instead of a list view meaning cells are not reused.
@fatiherdogan3838
@fatiherdogan3838 6 місяців тому
I would not use the swift sorting algorithms for this case. You can get the data sorted from firebase directly. Let firebase does the job.
@user-mk6or1gi7v
@user-mk6or1gi7v 10 місяців тому
I want to create a simple app where the messages pop up. I finished the MessageField, Messagebubble, and TitleRow. How do I let the chat bubbles post during the scroll?
@octopro8937
@octopro8937 Рік тому
Hello DesignCode, I have a question. So basically the place where you type what you want to send the "Enter message here" thing, the background is black (I'm using dark mode) when I switch dark mode off it becomes white (it's not the rounded box that says "Enter message here" it is the background behind that which is a rectangle
@josuesaavedra6175
@josuesaavedra6175 Рік тому
If you are using a custom color that you created when you created it there is an option to make it sensitive and change depending on dark mode and light mode or you can set it to universal. If you do not want the background color to change, you can set the custom color to universal.
@monnydhingra6369
@monnydhingra6369 Рік тому
how to run this on two different simulators?
@stephaniewagstaff6563
@stephaniewagstaff6563 2 роки тому
I really enjoyed this tutorial but about 30 minutes in when we started coding with firestore in Xcode and so many words that I had never heard before were used without explanation left me so lost. I only say this to let you know not to be critical, because I was really enjoying the lecture and would’ve loved hearing your explanations because I think I would’ve understood you.
@lifebystefnJas
@lifebystefnJas Рік тому
Not scrolling to the last chat, used if lets for the id and its not even getting called... any ideas?
@kpsfoot4290
@kpsfoot4290 2 роки тому
Wonderful but is it possible to have a tuto on how to make a comment via firebase?
@DesignCodeTeam
@DesignCodeTeam 2 роки тому
Hi! Glad you enjoyed the video! If you want to save comments in Firestore, you can just create a collection called "comments" and follow the same logic as described in this tutorial to get real-time updates from Firestore. - Stephanie
@markme7092
@markme7092 2 роки тому
Hi Stephanie, My project requirement is User can post the name once in every 30 minutes in SwiftUI, how to achieve that functionality ?
@DesignCodeTeam
@DesignCodeTeam 2 роки тому
Hi Mark, I suggest you set up a timer (see developer.apple.com/documentation/foundation/timer or www.hackingwithswift.com/quick-start/swiftui/how-to-use-a-timer-with-swiftui) and once the time has run out, you can unlock the possibility to add a new name. - Stephanie
@SeriousCat5000
@SeriousCat5000 2 роки тому
Sarah is obviously a power user since she does all her messaging directly from the Firebase back-end.
@SeriousCat5000
@SeriousCat5000 2 роки тому
In all seriousness, this was a great video. I picked up some good ideas from the custom textfield and how to pass objects around using environment objects.
@techgeek885
@techgeek885 16 годин тому
Great video... can anyone helpme how can i create collection from app side
@user-we2si6ji5l
@user-we2si6ji5l 5 місяців тому
Dear Madam., Can we talk in this like vedio, audio chat? And send voice mail..?
@TheSwiftSolutions
@TheSwiftSolutions Рік тому
its very helpful but i am unable to update scroll to id mean scroll is not moving to bottom while opening chat its working perfect during typing msgs but not working at open chat.....
@30guarino
@30guarino Рік тому
I'm working on that as well....
@30guarino
@30guarino Рік тому
Got it!! ...So underneath the .onChange modifier....put .onAppear { messageManager.getMessages }
@scardera
@scardera Рік тому
Its a great tutorial but your lacking codes. Sarah will see the result as you see it since messages are stored as a received true/false of your point of view.
@htpa2929
@htpa2929 Рік тому
Why am I getting error in this part? 32:13?
@user-it2un5ml9v
@user-it2un5ml9v 8 місяців тому
i am also getting document request error code7
@mahaaziiz6941
@mahaaziiz6941 Рік тому
Thank you for this video it is very helpful.. I need to ask you about something in the direct message .. where can I contact you ?
Build a Fasting Timer App in SwiftUI - Complete Course
56:46
DesignCode
Переглядів 19 тис.
Build a FaceID Authentication System in SwiftUI
38:52
DesignCode
Переглядів 36 тис.
маленький брат прыгает в бассейн
00:15
GL Show Russian
Переглядів 1,1 млн
Эта Мама Испортила Гендер-Пати 😂
00:40
Глеб Рандалайнен
Переглядів 1,2 млн
Connect Firebase to Xcode: A Step-by-Step Tutorial | Firebase Bootcamp #1
21:07
Build a SwiftUI to-do app from scratch with Realm Crash Course
42:40
Building a scalable, modularized, testable app from scratch
21:31
Android Developers
Переглядів 151 тис.
Firebase Setup | To Do App | FlutterFlow for Beginners
6:54
FlutterFlow
Переглядів 9 тис.
SwiftUI Push Notifications Crash Course
15:57
DesignCode
Переглядів 17 тис.
Create a Shopping App with Apple Pay in SwiftUI from scratch - Part 2
39:49