You can use Firebase Authentication to allow users to sign in to your app using one or more sign-in methods, including email address and password sign-in, and federated identity providers such as Google Sign-in and Facebook Login. This tutorial gets you started with Firebase Authentication by showing you how to add email address and password sign-in to your app.
Connect your app to Firebase
- Install the Firebase SDK .
- In the Firebase console , add your app to your Firebase project.
Add Firebase Authentication to your app
Use Swift Package Manager to install and manage Firebase dependencies.
- In Xcode, with your app project open, navigate to File > Add Packages .
- When prompted, add the Firebase Apple platforms SDK repository:
- Choose the Firebase Authentication library.
- Add the
-ObjCflag to the Other Linker Flags section of your target's build settings. - When finished, Xcode will automatically begin resolving and downloading your dependencies in the background.
https://github.com/firebase/firebase-ios-sdk.git
(Optional) Prototype and test with Firebase Local Emulator Suite
Before talking about how your app authenticates users, let's introduce a set of tools you can use to prototype and test Authentication functionality: Firebase Local Emulator Suite . If you're deciding among authentication techniques and providers, trying out different data models with public and private data using Authentication and Firebase Security Rules , or prototyping sign-in UI designs, being able to work locally without deploying live services can be a great idea.
An Authentication emulator is part of the Local Emulator Suite , which enables your app to interact with emulated database content and config, as well as optionally your emulated project resources (functions, other databases, and security rules).
Using the Authentication emulator involves just a few steps:
- Adding a line of code to your app's test config to connect to the emulator.
- From the root of your local project directory, running
firebase emulators:start. - Using the Local Emulator Suite UI for interactive prototyping, or the Authentication emulator REST API for non-interactive testing.
A detailed guide is available at Connect your app to the Authentication emulator . For more information, see the Local Emulator Suite introduction .
Now let's continue with how to authenticate users.
Initialize the Firebase SDK
In your app delegate, first import the Firebase SDK:
Swift
import
FirebaseCore
.
swift

