Home

Awesome

<!-- This source file is part of the Stanford Spezi open-source project. SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) SPDX-License-Identifier: MIT -->

Spezi Firebase

Build and Test codecov DOI

Integrate Google Firebase services into your Spezi application.

Overview

This Module allows you to use the Google Firebase platform as a managed backend for authentication and data storage in your apps built with the Spezi framework.

We currently implement support for Authentication, Storage, and Firestore services.

Setup

You need to add the Spezi Firebase Swift package to your app in Xcode or Swift package.

[!IMPORTANT]
If your application is not yet configured to use Spezi, follow the Spezi setup article# to set up the core Spezi infrastructure.

Examples

The below section walks you through the necessary steps to set up the Spezi Firebase Module for your application.

1. Set up your Firebase Account

To connect your app to the Firebase cloud platform, you will need to first create an account at firebase.google.com then start the process to register a new iOS app.

Once your Spezi app is registered with Firebase, place the generated GoogleService-Info.plist configuration file into the root of your Xcode project. You do not need to add the Firebase SDKs to your app or initialize Firebase in your app, since the Spezi Firebase Module will handle these tasks for you.

You can also install and run the Firebase Local Emulator Suite for local development. To do this, please follow the installation instructions.

2. Add Spezi Firebase as a Dependency

First, you will need to add the SpeziFirebase Swift package to your app in Xcode or Swift package.

3. Register the Spezi Firebase Modules

In the example below, we configure our Spezi application to use Firebase Authentication with both email & password login and Sign in With Apple, and Cloud Firestore for data storage.

import Spezi
import SpeziAccount
import SpeziFirebaseAccount
import SpeziFirebaseStorage
import SpeziFirestore
import SwiftUI


class ExampleDelegate: SpeziAppDelegate {
    override var configuration: Configuration {
        Configuration {
            AccountConfiguration(configuration: [
                .requires(\.userId),
                .collects(\.name)
            ])
            Firestore()
            FirebaseAccountConfiguration[
                authenticationMethods: [.emailAndPassword, .signInWithApple]
            ]
        }
    }
}

For more information, please refer to the API documentation.

The Spezi Template Application

The Spezi Firebase Module comes pre-configured in the Spezi Template Application, which is a great way to get started on your Spezi Application.

Contributing

Contributions to this project are welcome. Please make sure to read the contribution guidelines and the contributor covenant code of conduct first.

License

This project is licensed under the MIT License. See Licenses for more information.

Spezi Footer Spezi Footer