- Launch Xcode and open the project or workspace where you want to add the packages.
- In the menu bar, go to:
File > Add Package Dependencies...
- Enter the Package URL:
https://github.com/firebase/FirebaseUI-iOS
- In the
Dependency Rule
dropdown, selectExact Version
and set the version to15.1.0-alpha
in the resulting text input. - Select target(s) you wish to add to your app (currently
FirebaseAuthSwiftUI
,FirebaseGoogleSwiftUI
,FirebaseFacebookSwiftUI
andFirebasePhoneAuthSwiftUI
are available).FirebaseAuthSwiftUI
is required and contains the Email provider API. - Press the
Add Packages
button to complete installation.
- Follow step 2, 3 & 5 on adding Firebase to your SwiftUI app.
- You should now update your app entry point to look like this:
import FirebaseAuthSwiftUI
import FirebaseCore
import SwiftUI
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [
UIApplication.LaunchOptionsKey: Any
]?) -> Bool {
FirebaseApp.configure()
return true
}
}
@main
struct FirebaseSwiftUIExampleApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
struct ContentView: View {
let authService: AuthService
init() {
let configuration = AuthConfiguration()
authService = AuthService(
configuration: configuration,
)
.withEmailSignIn()
}
var body: some View {
AuthPickerView().environment(authService)
}
}
- For a more complete example, see the SwiftUI sample app.
You can create an AuthConfiguration
instance and pass it to the AuthService
as demonstrated above. Here are the options:
public struct AuthConfiguration {
// hides cancel buttons when you don't want a flow to be interrupted
let shouldHideCancelButton: Bool
// stop users from being able to swipe away sheets/modal
let interactiveDismissEnabled: Bool
// automatically upgrade anonymous users so that they are linked with account being used to sign-in
let shouldAutoUpgradeAnonymousUsers: Bool
// custom string bundle for string localizations
let customStringsBundle: Bundle?
// terms of service URL
let tosUrl: URL?
// privacy policy URL
let privacyPolicyUrl: URL?
// action code settings for email sign in link
let emailLinkSignInActionCodeSettings: ActionCodeSettings?
// action code settings verifying email address
let verifyEmailActionCodeSettings: ActionCodeSettings?
public init(shouldHideCancelButton: Bool = false,
interactiveDismissEnabled: Bool = true,
shouldAutoUpgradeAnonymousUsers: Bool = false,
customStringsBundle: Bundle? = nil,
tosUrl: URL? = nil,
privacyPolicyUrl: URL? = nil,
emailLinkSignInActionCodeSettings: ActionCodeSettings? = nil,
verifyEmailActionCodeSettings: ActionCodeSettings? = nil)
}
Note: Both
tosUrl
andprivacyPolicyUrl
have to be set for them to be rendered in the UI.
- Ensure the provider is installed from step 1 (e.g. if configuring Google provider, you need to install
FirebaseGoogleSwiftUI
package). - Ensure you have called the relevant API on
AuthService
to initialise the provider. Example of Email and Google provider initialization:
let authService = AuthService()
.withEmailSignIn()
.withGoogleSignIn()
Note: There may be additional setup for each provider typically in the AppDelegate. See example app for setup.
- General API
- Auto upgrade anonymous user account linking (if configured).
- Sign out
- Email/Password
- Sign-in/Create user
- Password recovery
- Email link sign-in
- Google
- Sign in with Google
- Facebook
- Sign in with Facebook limited login
- Sign in with Facebook classic login
- Phone Auth
- Verify phone number
- Sign in with phone number
- User
- Update password
- Delete user
- Verify email address
- Customization/theming for Views is not available directly in the default view. To create a custom view, build your own auth picker view from the provider components.
- The providers available are Email, Phone, Google and Facebook.
- String localizations have been ported over and used where possible from the previous implementation, but new strings will only have English translations for the time being.
- The UI has not been polished and is subject to change once design has been finalized.
Please file feedback in the repository's issue tracker.