Add Google Sign-In and Facebook Login to an iOS app by configuring each provider's developer console, installing their SDKs, and authenticating through Firebase Auth with provider-specific credentials.
Why Firebase for Social Login
Firebase Authentication unifies multiple identity providers behind a single API. Facebook Login returns a Facebook credential that Firebase converts to a Firebase user. Google Sign-In returns a Google credential through the same flow.
The app retrieves displayName, email, and photoURL from Auth.auth().currentUser regardless of the sign-in method. Logout is a single Auth.auth().signOut call for all providers. Users can link multiple providers to the same account.
Prerequisites
Create a Firebase project with email and password authentication enabled. Add the GoogleService-Info.plist to your Xcode project. Install FirebaseAuth using Swift Package Manager.
Part 1: Facebook Login Integration
Configuring the Facebook App
Go to the Facebook for Developers site and sign in. Create a new app. Choose Authenticate and request data from users with Facebook Login as the use case. Note the App ID and App Secret from the app dashboard. Add the iOS platform with your app's bundle identifier.
Enabling Facebook Login in Firebase
Open the Firebase Console. Go to Authentication and select Sign-in Method. Click Add new provider. Choose Facebook. Enter the Facebook App ID and App Secret. Firebase generates an OAuth Redirect URI. Copy this URI.
Go to the Facebook app dashboard. Under Facebook Login and Settings, paste the URI into Valid OAuth Redirect URIs.
Installing the Facebook iOS SDK
In Xcode 26, go to File and select Add Package Dependencies. Enter the Facebook iOS SDK repository:
https://github.com/facebook/facebook-ios-sdk
Add FacebookCore and FacebookLogin to your target.
Configuring Info.plist
Open Info.plist as Source Code. Add entries for the Facebook App ID, Client Token, display name, and URL scheme:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fbYOUR_APP_ID</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>YOUR_APP_ID</string>
<key>FacebookClientToken</key>
<string>YOUR_CLIENT_TOKEN</string>
<key>FacebookDisplayName</key>
<string>Your App Name</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-share-api</string>
</array>
Replace YOUR_APP_ID, YOUR_CLIENT_TOKEN, and Your App Name with actual values from the Facebook Developer dashboard.
Configuring AppDelegate
Import FacebookCore. Initialize the SDK in didFinishLaunchingWithOptions:
import FacebookCore
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
return true
}
Add the URL handler for Facebook redirects:
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
ApplicationDelegate.shared.application(app, open: url, sourceApplication: options[.sourceApplication] as? String, annotation: options[.annotation])
}
Implementing Facebook Login
The login flow uses LoginManager to obtain a Facebook access token, then converts it to a Firebase credential:
@IBAction func facebookLoginTapped(_ sender: UIButton) {
let loginManager = LoginManager()
loginManager.logIn(permissions: ["public_profile", "email"], from: self) { result, error in
if let error = error {
self.showAlert("Facebook Login Error", error.localizedDescription)
return
}
guard let accessToken = AccessToken.current else { return }
let credential = FacebookAuthProvider.credential(withAccessToken: accessToken.tokenString)
Auth.auth().signIn(with: credential) { result, error in
if let error = error {
self.showAlert("Firebase Login Error", error.localizedDescription)
return
}
self.navigateToMainView()
}
}
}
LoginManager.logIn opens the Facebook login dialog. On success, AccessToken.current contains the token. FacebookAuthProvider.credential converts it to a Firebase-compatible credential. Auth.auth().signIn authenticates with Firebase.
Creating Facebook Test Accounts
Facebook apps in development mode restrict login to test users. In the Facebook Developer dashboard, go to App Roles and Test Users. Create test users and note their credentials for testing.
Part 2: Google Sign-In Integration
Enabling Google Sign-In in Firebase
In the Firebase Console, go to Authentication and Sign-in Method. Click Add new provider and select Google. Enter a public-facing project name and your support email. Save the configuration.
Installing the Google Sign-In SDK
In Xcode, add a new package dependency:
https://github.com/google/GoogleSignIn-iOS
Adding a Custom URL Scheme
Open GoogleService-Info.plist. Find the REVERSED_CLIENT_ID value. Copy it. In Xcode, select your project. Select your target and go to the Info tab. Expand URL Types. Click the plus button. Paste the reversed client ID into URL Schemes.
Implementing Google Sign-In
Configure GIDSignIn with the Firebase client ID and call signIn:
import GoogleSignIn
@IBAction func googleLoginTapped(_ sender: UIButton) {
guard let clientID = FirebaseApp.app()?.options.clientID else { return }
let config = GIDConfiguration(clientID: clientID)
GIDSignIn.sharedInstance.configuration = config
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let rootViewController = windowScene.windows.first?.rootViewController else { return }
GIDSignIn.sharedInstance.signIn(withPresenting: rootViewController) { result, error in
if let error = error {
self.showAlert("Google Sign-In Error", error.localizedDescription)
return
}
guard let user = result?.user,
let idToken = user.idToken?.tokenString else { return }
let credential = GoogleAuthProvider.credential(withIDToken: idToken, accessToken: user.accessToken.tokenString)
Auth.auth().signIn(with: credential) { result, error in
if let error = error {
self.showAlert("Firebase Login Error", error.localizedDescription)
return
}
self.navigateToMainView()
}
}
}
The clientID comes from FirebaseApp.app().options.clientID. GIDSignIn.sharedInstance.signIn presents the Google account picker. The result provides idToken and accessToken. GoogleAuthProvider.credential creates the Firebase credential.
Handling URLs for Both Providers
Update AppDelegate to handle both Facebook and Google callback URLs:
import GoogleSignIn
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
if url.absoluteString.contains("fb") {
return ApplicationDelegate.shared.application(app, open: url, sourceApplication: options[.sourceApplication] as? String, annotation: options[.annotation])
}
return GIDSignIn.sharedInstance.handle(url)
}
Linking Multiple Providers to One Account
Firebase allows linking multiple providers to a single user account. A user who registers with email and password can later link a Facebook or Google account:
let credential = FacebookAuthProvider.credential(withAccessToken: accessToken.tokenString)
Auth.auth().currentUser?.link(with: credential) { result, error in
// User can now sign in with either email or Facebook
}
Best Practices for Social Login
Request minimal permissions. public_profile and email are sufficient for basic authentication. Additional permissions reduce conversion rates.
Test with development accounts before going live. Facebook requires test users in development mode. Google Sign-In works with any Google account but requires the correct URL scheme configuration.
Provide a privacy policy URL and user data deletion URL before switching Facebook apps to production mode. These are required for compliance with platform policies.
Summary
This tutorial covered the complete implementation process from setup to working code. You now have a functional implementation that you can extend and customize for your own projects. The same patterns apply to related features in the iOS ecosystem.
Frequently Asked Questions
What Xcode version do I need for this tutorial? This tutorial uses Xcode 26 with Swift 6.2. The code examples work with any recent version of Xcode that supports the frameworks used here.
What are the prerequisites for this tutorial? You need Xcode installed on a Mac and basic familiarity with Swift programming. No prior experience with the specific framework is required.