Swiftpack.co - Flowductive/easy-firebase as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Flowductive.
Flowductive/easy-firebase 0.2.0
A Swift wrapper for all things Firebase. Quickly implement Firestore and Authentication on iOS and macOS using native Swift protocols and methods.
⭐️ 8
🕓 2 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/Flowductive/easy-firebase.git", from: "0.2.0")

Social Preview

Firebase for iOS and macOS made easy.

🍏 Third-party authentication done in a single line of code

✉️ Send and receive Firestore documents in a snap

😀 Predefined user protocols with built-in features

🔥 Firebase solutions in one native Swift package

What is EasyFirebase?

EasyFirebase is a Swift wrapper for all things Firebase. Save hours from implementing the Firebase code in your projects repeatedly. EasyFirebase makes document storage and retrieval easier by providing intuitive protocols for Firestore. EasyFirebase makes authentication easier with the EasyUser protocol and simple one-line sign-in with Google and Apple. EasyFirebase is cross-platform and works with both iOS and macOS.

Completed Features

  • Firestore Support
    • Built-in Document protocol
    • Document storage
    • Document removal
    • Document retrieval
    • Update listeners
    • Built-in cacheing
    • Easy linking
  • Authentication Support
    • EasyUser protocol
    • Email auth
    • Sign In with Google
    • Sign In with Apple
    • Robust user management
  • Storage Support
    • Data storage
    • Safe data overriding
    • Data removal
    • Data upload task visibility
  • Cloud Messaging Support
    • Built-in user notifications
    • Built-in MessagingNotification protocol
    • Built-in 3P notifications
    • User notification settings

All the above features are cross-platform and are supported on both iOS and macOS.

⭐️ This means EasyFirebase is the quickest way to implement Sign In with Google on macOS! ⭐️

Get Started

Add EasyFirebase to your project using Swift Package Manager:


Import EasyFirebase:

import EasyFirebase

Configure at app launch:

// You don't need to call FirebaseApp.configure() when this is called!

🔥 Firestore Feature Showcase

Built-in Document protocol

Save time writing model classes with the built-in Document protocol:

class Car: Document {
  // These properties are inherited from Document
  var id: String = UUID().uuidString
  var dateCreated: Date = Date()
  // Define your own custom properties
  var make: String
  var model: String
  var year: Int
  init(make: String, model: String, year: Int) {
    // ...

Document Storage

Store documents anywhere in your code:

var myCar = Car(make: "Toyota", model: "Corolla", year: 2017)

// Store the car instance in the 'car' collection in Firestore

// Static method that does the same as above

Document Retrieval

Grab documents easily without needing to specify a collection name:

EasyFirestore.Retrieval.get(id: myCarID, ofType: Car.self) { car in
  guard let car = car else { return }
  self.myOtherCar = car

Update Listeners

Grab documents and update the local instance when changed in Firestore:

EasyFirestore.Listening.listen(to: otherCarID, ofType: Car.self, key: "myCarListenerKey") { car in
  // Updates when changed in Firestore
  guard let car = car else { return }
  self.myOtherCar = car

Built-In Cacheing

EasyFirestore will automatically cache fetched documents locally and will use the cached doucments when retrieving to reduce your Firestore read count.

// EasyFirebase will automatically cache fetched objects for you, here is a manual example

// Get locally cached objects instantly. Retrieving objects using EasyFirestore.Retrieval will grab cached objects if they exist
var cachedCar = EasyFirestore.Cacheing.grab(myCarID, fromType: Car.self)

Easy Linking

Link child documents to an array of IDs in a parent document:

var car1 = Car(make: "Toyota", model: "Corolla", year: 2017)
var car2 = Car(make: "Honda", model: "Civic", year: 2019)

var dealership = Dealership(name: "Los Angeles Dealership")

// Set and assign the Toyota Corolla to the Los Angeles Dealership
car1.setAssign(to: \.cars, in: dealership)

// Set and assign the Honda Civid to the Los Angeles Dealership
car2.assign(to: \.cars, in: dealership)

🔑 Authentication Feature Showcase

Easy User Protocol

Save time writing user classes with the built-in EasyUser procotol:

class MyUser: EasyUser {
  // EasyUser comes pre-built with these automatically updated properties
  var lastSignon: Date
  var displayName: String
  var username: String
  var email: String
  var appVersion: String
  var deviceToken: String?
  var notifications: [MessagingNotification]
  var disabledMessageCategories: [MessageCategory]
  var progress: Int
  var id: String
  var dateCreated: Date
  // Define your own custom properties
  var cars: [DocumentID]

  // ...

Email Auth

Authenticate with an email and password easily:

EasyAuth.createAccount(email: "easy.firebase@example.com", password: "76dp2[&y4;JLyu:F") { error in
  if let error = error {
  } else {
    // Account created!

EasyAuth.signIn(email: "easy.firebase@example.com", password: "76dp2[&y4;JLyu:F") { error in
  // ...

Sign In with Google

Authenticate with Google:

// iOS
EasyAuth.signInWithGoogle(clientID: "xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") { error in
  // ...

// macOS
EasyAuth.signInWithGoogle(clientID: "xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                          secret: "GOCSPX-xxxxxxxxxxxxxxxxxxx-xxxxxxxx") { error in
  // ...

Sign In with Apple

Authenticate with Apple:

// iOS + macOS

Robust User Management

Quickly update and manage EasyAuth users:

// Send a verfication email to the currently signed-in user
EasyAuth.Manage.sendEmailVerification(completion: { error in })
// Upload and update the current user's profile photo
EasyAuth.Manage.updatePhoto(with: myPhotoData, completion: { error in })
// Send the current user's password reset form to a specified email
EasyAuth.Manage.sendPasswordReset(toEmail: "myResetEmail@example.com", completion: { error in })
// Update the current user's display name
EasyAuth.Manage.updateDisplayName(to: "New_DisplayName", completion: { error in })
// Update the current user's password
EasyAuth.Manage.updatePassword(to: "newPassword", completion: { error in })
// Delete the current user
EasyAuth.Manage.deleteUser(completion: { error in })

📦 Storage Feature Showcase

Data Storage

Quickly assign data to Firebase Storage using a single line of code.

// Upload image data and get an associated URL
EasyStorage.put(imageData, to: StorageResource(id: user.id)) { url in }

// EasyStorage will automatically delete existing images matching the same ID (if in the same folder)
EasyStorage.put(imageData,to: StorageResource(id: user.id, folder: "myFolder"), progress: { updatedProgress in
  // Update progress text label using updatedProgress
}, completion: { url in
  // Handle the image's URL

☁️ Cloud Messaging Feature Showcase

Built-in User Notifications

Easily send and notify other users without all the tedious setup. Just add a serverKey from Firebase Console.

// Set your Server Key
EasyMessaging.serverKey = "xxxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxx-xxxxx-xxxxxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxx"

// Create the notification
let notification = MessagingNotification("Message body", from: me, in: "Test Category")

// Send the notification to the user
// Appends to the notifications property, unless the specified category is in the user's disabledMessageCategories
EasyMessaging.send(notification, to: you)


Stars: 8
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

2 weeks ago

This update adds support for Cloud Messaging and Firebase Storage. It also adds support for user management with EasyAuth.Manage.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics