A Swift Pakage for adding a turnkey sign up/sign in to Firebase workflow for your SwiftUI apps. After configuring your app for Firebase/Firestore connectivity, a single line of code will create the workflow for signing up and signing in to a Firebase account.
- Sign up and sign in in with email
- Sign up and sign in with Apple
- Password reset option sign in with email
- Firebase account deletion functionality included.
- Custom colors and project image
For detailed instructions and link to video see the documentation page: https://stewartlynch.github.io/FBAuthentication/
- Create your XCode project and copy the Bundle ID.
- Log in to the Firebase Console and create a new project.
- Add a new iOS App and enter your Bundle ID for the app.
- Download the GoogleServices-Info.plist and drop it into your Xcode project.
- Add Authentication by choosing Email/Password and Apple.
- Add Firestore Database service to your project.
- Log into your Apple Developer account and in the Certificates, IDs and profiles section, enable Email Sources for the firebase project.
- Add Sign in with Apple capability to your Xcode app.
- Add the FBAuthentication package to your Xcode project using the URL from this page https://github.com/StewartLynch/FBAuthentication/
- Import Firebase and FBAuthentication in your @main file and configure Firebase then inject an instance of UserInfo() into the environment.
- Design your
HomeView
view in your app which will be the first page that you app goes to after a successfull authentication. - Update ContentView by importing
FBAuthentication
, add an instance of userInfo as an@EnvironmentObject
then replace the body with a call toLoadingView
passing in yourHomeView
as the startView
import SwiftUI
import FBAuthentication
struct ContentView: View {
@EnvironmentObject var userInfo: UserInfo
var body: some View {
LoadingView(startView: HomeView())
}
}
Test your app by signing in via email and Apple
Implement logging out using
FBAuth.logout { (result) in
print("Logged out")
}
To access the profile where you will be able to update the user name or delete the account and all related data, present a sheet to the ProfileView
.sheet(isPresented: $showProfile {
ProfileView()
}