The app demonstrates how to use Firebase in a SwiftUI iOS app

Overview

Firebase SwiftUIDemo app

This app demonstrates how to use Firebase in a SwiftUI iOS app.

Firebase Setup

  1. Go to firebase.com
  2. Click new project.
  • Copy app bundle identifier from the top-left file in Xcode.
  1. Create a new iOS app.
  2. Paste app bundle identifier as well as give it a name.

Pods Setup

  1. Open a terminal window in your project's root.
  2. Type pod init
  3. Click through the steps to add Firebase to your project.
  4. Choose the Firebase libraries you want to use to setup the project.
  1. Open with a text editor the new pod file.
  • vim Podfile
  1. Install the selected libraries
  • pod install
  • Note: if you need to remove pods, then you do that through pod install as well after deleting the library from the Podfile

Database Setup

In Firebase, there are two databases available:

  1. Firestore
  2. Realtime

The Firestore database is the latest available database, so we recommend this one, because it builds on lessons learned from the older Realtime database. See here for more details on the two.

You create the database in the top-left setting of the Firebase console under Build -> Firestore Database

When you first create the database, you get to choose a location. Note that you cannot change this location once you create your app. Therefore, choose the location that most closely will serve your users. You can see all of the available locations here

If you want a database, which goes global, then you should check out FaunaDB.

Database Interaction

We create an instance of the Firebase database within our project. This instance automatically uses our GoogleService-Info.plist file in order to authenticate with our Firebase app. We must initialize this database in the init method for our app.

    init() {
        FirebaseApp.configure()
        
        // Create documents below
        makeReservation()
    }
    
    func makeReservation() {
        
        // Reference the Cloud Firestore database
        let db = Firestore.firestore()
        
        // Access the reservations collection, or creates it, if not already created
        let reservations = db.collection("reservations")
        
        // Create a document with a given identifier
        reservations.document("test123").setData([
            "name": "Carol",
            "people": 22
        ])
        
        // Create document with a unique identifier
        reservations.document().setData(["name" : "Tom"])
        
        // Create document with given data, then assign it to a constant
        let document = reservations.addDocument(data: [
            "name": "Sue",
            "people": 10
        ])
        
        // Work with the document
        
        
    }
You might also like...
SwiftUI + Firebase template
SwiftUI + Firebase template

SwiftUI + Firebase template project This is a template project with SwiftUI and Firebase. You can create an iOS with SwiftUI and Firebase right away w

 iOS Open-Source Telematics App with Firebase© integration
iOS Open-Source Telematics App with Firebase© integration

Open-source telematics app for iOS. The application is suitable for UBI (Usage-based insurance), shared mobility, transportation, safe driving, tracking, family trackers, drive-coach, and other driving mobile applications

Food Order App for iOS. VIPER pattern, Alamofire and Firebase used.
Food Order App for iOS. VIPER pattern, Alamofire and Firebase used.

Nibble Yemek Sipariş Uygulaması Techcareer.net Techmasters IOS Bootcamp bitirme ödevi için hazırladığım bir yemek sipariş uygulaması. API KEY SON GEÇE

Firebase Quickstart Samples for iOS

Firebase Quickstarts for iOS A collection of quickstart samples demonstrating the Firebase APIs on iOS. Each sample contains targets for both Objectiv

IOS mobile application that uses URLSession and Firebase
IOS mobile application that uses URLSession and Firebase

DogApp IOS mobile application that uses URLSession and Firebase. First a dog ima

Firebase Cloud Firestore support library for iOS. 🧢
Firebase Cloud Firestore support library for iOS. 🧢

🧢 Ballcap-iOS Ballcap is a database schema design framework for Cloud Firestore. Why Ballcap Cloud Firestore is a great schema-less and flexible data

A grocery list app for families written in Swift using Firebase Realtime Database

FamiList | Grocery list app in Swift FamiList is a grocery list app for families written in Swift using Firebase Realtime Database. You can add differ

A detailed clone of the Instagram app built with Firebase
A detailed clone of the Instagram app built with Firebase

[This repository is no longer being maintained] InstagramClone A detailed clone

Learning App with Firebase Auth
Learning App with Firebase Auth

Learning App Displays how to make a learning app with Swift, iOS's programming l

Owner
Andrew Gholson
Andrew Gholson
Todo is an iOS App written in Swift. This app is used for an online video training course. This app demonstrates how to use UITableViewController.

Todo Todo is an iOS App written in Swift. This app is used for an online video training course. This app demonstrates how to use UITableViewController

Jake Lin 273 Dec 29, 2022
Firebase Analytics Firebase Notification Alamofire KingFisher Ombdb API

MovieOmdbApp Firebase Analytics Firebase Notification Alamofire KingFisher Ombdb

Kaya 0 Dec 20, 2021
An experiment to use Firebase and React Native to build a wwdc.family app

wwdc.family This is an experiment to use Firebase and React Native to build a wwdc.family app. Don't use that source code as reference - I have no pri

WWDC Family 190 Feb 9, 2022
Ready use service for Firebase. Included interface, recored devices and notifications.

SPProfiling Ready use service with using Firebase. Included interface, manage auth process, recored devices and profile data. Installation Ready for u

Ivan Vorobei 13 Oct 29, 2022
Aplikasi iOS Simulasi CRUD Stok Barang dengan SwiftUI, Firebase CLI & Firestore

iStockery Aplikasi iStockery adalah aplikasi stok inventory berbasis iOS yang dibuat menggunakan Firebase (Firestore) secara Local dengan fitur CRUD d

DK 7 Aug 1, 2022
Simple Todo Application using SwiftUI / Firebase / Redux.

Simple Todo Application using SwiftUI/Firebase/Redux/Combine. Light _ _ _ _ Dark _ _ _ Feature Use SwiftUI fully. Use Firebase. Authentication Cloud F

Suguru Kishimoto 337 Dec 25, 2022
Completed Project for Authentication in SwiftUI using Firebase Auth SDK & Sign in with Apple

Completed Project for Authentication in SwiftUI using Firebase Auth SDK & Sign in with Apple Follow the tutorial at alfianlosari.com Features Uses Fir

Alfian Losari 43 Dec 22, 2022
SwiftUI, Firebase, Kingfisher, googleapis

SwiftUI-KokaiByWGO Xcode Version 12.0 SwiftUI, Firebase, Kingfisher, googleapis Learn Thai with pictures and sounds Note : This version have no CMS so

Waleerat S. 0 Oct 6, 2021
Social Media platform build with swiftUI and Firebase with google and apple account integration for Signing In Users

Social Media platform build with swiftUI and Firebase with google and apple account integration for Signing In Users . Providing Users availability to upload posts and images add caption allowing other users to comment , with Find section to explore new people , new stories , User Profile section to allow the user to take control of his account .

Devang Papinwar 2 Jul 11, 2022
A SwiftUI component which handles logging in with Apple to Firebase

Login with Apple Firebase SwiftUI I made this SwiftUI component to handle logging in with Apple to Firebase. Demo Gif Usage in SwiftUI struct ContentV

Joe Hinkle 153 Dec 23, 2022