{"id":22829338,"url":"https://github.com/swiftfulthinking/swiftfulfirebaseauth","last_synced_at":"2025-07-02T00:02:01.299Z","repository":{"id":203559517,"uuid":"709888374","full_name":"SwiftfulThinking/SwiftfulFirebaseAuth","owner":"SwiftfulThinking","description":"Firebase Authentication for Swift projects.","archived":false,"fork":false,"pushed_at":"2024-10-04T22:04:10.000Z","size":69,"stargazers_count":62,"open_issues_count":3,"forks_count":26,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-19T16:58:59.197Z","etag":null,"topics":["firebase-auth","signinwithapple","signinwithgoogle","swift","swift-package-manager","swiftui"],"latest_commit_sha":null,"homepage":"https://www.swiftful-thinking.com","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SwiftfulThinking.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-25T15:37:57.000Z","updated_at":"2025-02-17T19:41:15.000Z","dependencies_parsed_at":"2024-04-23T01:47:31.693Z","dependency_job_id":"d5b2d95d-6c05-4500-b2d2-c10d6c745f27","html_url":"https://github.com/SwiftfulThinking/SwiftfulFirebaseAuth","commit_stats":{"total_commits":49,"total_committers":6,"mean_commits":8.166666666666666,"dds":0.4693877551020408,"last_synced_commit":"1173b782ebf9acfc02e2d46ca1684f254ae878a8"},"previous_names":["swiftfulthinking/swiftfulfirebaseauth"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/SwiftfulThinking/SwiftfulFirebaseAuth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftfulThinking%2FSwiftfulFirebaseAuth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftfulThinking%2FSwiftfulFirebaseAuth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftfulThinking%2FSwiftfulFirebaseAuth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftfulThinking%2FSwiftfulFirebaseAuth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SwiftfulThinking","download_url":"https://codeload.github.com/SwiftfulThinking/SwiftfulFirebaseAuth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftfulThinking%2FSwiftfulFirebaseAuth/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263052428,"owners_count":23406103,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["firebase-auth","signinwithapple","signinwithgoogle","swift","swift-package-manager","swiftui"],"created_at":"2024-12-12T19:15:20.961Z","updated_at":"2025-07-02T00:02:01.158Z","avatar_url":"https://github.com/SwiftfulThinking.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨\n\n ⚠️ This repository is \u003cstrong\u003edeprecated\u003c/strong\u003e! It will remain available for those using it, but no further updates will be made. \n \n ⚠️ Please consider migrating to the new repos: \n - https://github.com/SwiftfulThinking/SwiftfulAuthenticating\n - https://github.com/SwiftfulThinking/SwiftfulAuthenticatingFirebase\n\n ⚠️ The new repos are restricted to iOS 17+, with Swift 6 and @Observable macro support.\n \n ⚠️ The new parent repo, `SwiftfulAuthenticating`, is dependency agnostic and decoupled from Firebase. This improves testability, mockability, and allows developers to pick-and-choose their auth source.\n\n ⚠️ Firebase Authentication can still be added to `SwiftfulAuthenticating` via `SwiftfulAuthenticatingFirebase`\n\n ⚠️ The new repo drops support for Sign In With Phone, as different auth sources handle this differently (tbd).\n\n🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨\n\n\n\n\n# SwiftfulFirebaseAuth 🤙\n\nConvenience methods to manage Firebase Authentication in Swift projects.\n\n- ✅ Sign In With Apple\n- ✅ Sign In With Google\n- ✅ Sign In With Phone\n\n```swift\nTask {\n     do {\n          let (userAuthInfo, isNewUser) = try await authManager.signInApple()\n          // User is signed in\n\n          if isNewUser {\n               // New user -\u003e Create user profile in Firestore\n          } else {\n               // Existing user -\u003e sign in\n          }\n     } catch {\n          // User auth failed\n     }\n}\n```\n\nSample project: https://github.com/SwiftfulThinking/SwiftfulFirebasePackagesExample\n\n## Setup\n\n\u003cdetails\u003e\n\u003csummary\u003e Details (Click to expand) \u003c/summary\u003e\n\u003cbr\u003e\n     \n### 1. Import the package to your project.\n* File -\u003e Swift Packages -\u003e Add Package Dependency\n* Add URL for this repository: https://github.com/SwiftfulThinking/SwiftfulFirebaseAuth.git\n\n### 2. Import the package to your file.\n```swift\nimport SwiftfulFirebaseAuth\n```\n\n### 3. Create one instance of AuthManager for your application.\n```swift\nlet authManager = AuthManager(configuration: .firebase)\n\n// Use Mock configuration to avoid running Firebase while developing (ex. for SwiftUI Previews).\nlet authManager = AuthManager(configuration: .mock(.signInAndOut))\n\n// Use Mock configurations to override settings for Previews.\n// .signInAndOut (default behavior)\n// .signedIn (starts signed in)\n// .signedOut (user starts signed out)\n#Preview {\n    MyView()\n            .environment(\\.authManager, AuthManager(configuration: .mock(.signedIn)))\n}\n```\n\n\n\n### 4. Configure your Firebase project.\nAdd the Firebase SDK to your application and configure() the SDK on launch.\n\n```swift\n@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate\n```\n```swift\nfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -\u003e Bool {\n     FirebaseApp.configure()\n     return true\n}\n```\n\n\u003c/details\u003e\n\n## Sign In With Apple\n\n\u003cdetails\u003e\n\u003csummary\u003e Details (Click to expand) \u003c/summary\u003e\n\u003cbr\u003e\n\nFirebase docs: https://firebase.google.com/docs/auth/ios/apple\n\n### 1. Enable Apple as a Sign-In Method in Firebase Authentication console.\n* Firebase Console -\u003e Authentication -\u003e Sign-in method -\u003e Add new provider\n\n### 2. Add Sign in with Apple Signing Capability to your Xcode project.\n* Xcode Project Navigator -\u003e Target -\u003e Signing \u0026 Capabilities -\u003e + Capability -\u003e Sign in with Apple (requires Apple Developer Account)\n\n### 3. Add Apple Button (optional)\n```swift\nSignInWithAppleButtonView()\n    .frame(height: 50)\n```\n\n### 4. Sign in\n\n```swift\ntry await authManager.signInApple()\n```\n\u003c/details\u003e\n\n\n## Sign In With Google\n\n\u003cdetails\u003e\n\u003csummary\u003e Details (Click to expand) \u003c/summary\u003e\n\u003cbr\u003e\n\nFirebase docs: https://firebase.google.com/docs/auth/ios/google-signin\n\n### 1. Enable Google as a Sign-In Method in Firebase Authentication console.\n* Firebase Console -\u003e Authentication -\u003e Sign-in method -\u003e Add new provider\n\n### 2. Update you app's the info.plist file.\n* Firebase Console -\u003e Project Settings -\u003e Your apps -\u003e GoogleService-Info.plist\n\n### 3. Add custom URL scheme (URL Types -\u003e REVERSED_CLIENT_ID)\n* GoogleService-Info.plist -\u003e REVERSED_CLIENT_ID\n* Xcode Project Navigator -\u003e Target -\u003e Info -\u003e URL Types -\u003e add REVERSED_CLIENT_ID as URL Schemes value\n\n### 4. Add Google Button (optional)\n```swift\nSignInWithGoogleButtonView()\n    .frame(height: 50)\n```\n\n### 5. Sign in\n```swift\nlet clientId = FirebaseApp.app()?.options.clientID\ntry await authManager.signInGoogle(GIDClientID: clientId)\n```\n\n\u003c/details\u003e\n\n## Sign In With Phone\n\n\u003cdetails\u003e\n\u003csummary\u003e Details (Click to expand) \u003c/summary\u003e\n\u003cbr\u003e\n\nFirebase docs: https://firebase.google.com/docs/auth/ios/phone-auth\n\n### 1. Enable Phone Number as a Sign-In Method in Firebase Authentication console.\n* Firebase Console -\u003e Authentication -\u003e Sign-in method -\u003e Add new provider\n\n### 2. Enable APNs notifications (silent push notifications).\n* Create an APNs Authentication Key in [Apple Developer Member Center](https://developer.apple.com/membercenter/index.action) (requires Apple Developer Account)\n* Certificates, Identifiers \u0026 Profiles -\u003e New Key for Apple Push Notifications service (APNs) -\u003e download .p8 file\n\n### 3. Upload APNs key to Firebase.\n* Firebase Console -\u003e Project Settings -\u003e Cloud Messaging -\u003e APNs Authentication Key\n\n### 4. Enable reCAPTCHA verification (optional?).\n* Firebase Console -\u003e Project Settings -\u003e Encoded App ID\n* Xcode Project Navigator -\u003e Target -\u003e Info -\u003e URL Types -\u003e add Encoded App ID as URL Schemes value\n\n### 5. Add UIDelegate methods to handle push notifications\n\n```swift\nfunc application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {\n     Auth.auth().setAPNSToken(deviceToken, type: .prod)\n}\n\nfunc application(_ application: UIApplication, didReceiveRemoteNotification notification: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -\u003e Void) {\n     if Auth.auth().canHandleNotification(notification) {\n          completionHandler(.noData)\n          return\n     }\n}\n    \nfunc application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -\u003e Bool {\n     if Auth.auth().canHandle(url) {\n          return true\n     }\n     return false\n}\n```\n\n### 6. Get the user's phone number\n* This SDK does NOT format phone numbers or provide UI for this. You must provide a string in the correct format.\n* Phone numbers have to be correctly formatted, such as \"+1 650-555-3434\" for US numbers.\n* See [Firebase Docs](https://firebase.google.com/docs/auth/ios/phone-auth) for details about phone number implementation\n* Possible resources for phone number formatting:\n     - https://stackoverflow.com/questions/32364055/formatting-phone-number-in-swift\n     - https://github.com/iziz/libPhoneNumber-iOS\n     - https://github.com/MojtabaHs/iPhoneNumberField\n\n### 7. Add Phone Number Button (optional)\n\n```swift\nSignInWithPhoneButtonView()\n     .frame(height: 50)\n```\n\n### 8. Send verification code to user's phone.\n\n```swift\ntry await authManager.signInPhone_Start(phoneNumber: phoneNumber)\n```\n\n### 9. Verify code and sign in\n```swift\ntry await authManager.signInPhone_Verify(code: code)\n```\n\n\u003c/details\u003e\n\n## Already Signed In\n\n\u003cdetails\u003e\n\u003csummary\u003e Details (Click to expand) \u003c/summary\u003e\n\u003cbr\u003e\n\n#### Synchronously get user's authentication info.\n```swift\nlet userAuthProfile: UserAuthInfo? = authManager.currentUser.profile\nlet userIsSignedIn: Bool = authManager.currentUser.isSignedIn\nlet userId: String? = authManager.currentUser.userId\n```\n\n\n#### Asynchronously listen for changes to user's authentication info.\n```swift\nTask {\n     for await authInfo in authManager.$currentUser.values {\n          let userAuthProfile: UserAuthInfo? = authInfo.profile\n          let userIsSignedIn: Bool = authInfo.isSignedIn\n          let userId: String? = authInfo.userId\n     }                \n}\n```\n\n#### Sign out or delete user's authentication.\n```swift\ntry authManager.signOut()\n```\n```swift\ntry await authManager.deleteAuthentication()\n```\n\n\u003c/details\u003e\n\n## Want to contribute?\nOpen a PR! New Sign-In Methods must use Swift Concurrency (async/await).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftfulthinking%2Fswiftfulfirebaseauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswiftfulthinking%2Fswiftfulfirebaseauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftfulthinking%2Fswiftfulfirebaseauth/lists"}