Skip to content

joehinkle11/Login-with-Apple-Firebase-SwiftUI

Repository files navigation

Login with Apple Firebase SwiftUI

I made this SwiftUI component to handle logging in with Apple to Firebase.

Demo Gif

Usage in SwiftUI

struct ContentView: View {
    var body: some View {
        SignInWithAppleToFirebase({ response in
            if response == .success {
                print("logged into Firebase through Apple!")
            } else if response == .error {
                print("error. Maybe the user cancelled or there's no internet")
            }
        })
    }
}

Setup

  1. Copy the entirety of the SignInWithAppleToFirebase folder to your repo. https://github.com/joehinkle11/Login-with-Apple-Firebase-SwiftUI/tree/master/LoginWithAppleFirebaseSwiftUI/SignInWithAppleToFirebase
  2. Add Firebase to your project https://firebase.google.com/docs/ios/setup?authuser=0
  3. Add sign in with Apple as a valid login method on your Firebase project at this link https://console.firebase.google.com/u/0/project/<YOUR_FIREBASE_PROJECT_ID>/authentication/providers

  1. Make sure you have Firebase properly in your Podfile and run pod install
...
 # Pods for LoginWithAppleFirebaseSwiftUI
 pod 'Firebase/Auth'
...
  1. Make sure you open the Xcode workspace generated by Cocopods (this is detailed in the Firebase tutorial in step 2)
  2. Add Sign In with Apple to your app's id configuration at https://developer.apple.com/account/resources/identifiers/list Remove

  1. Add Sign in with Apple to your project's capabilities

  1. Add the SignInWithAppleToFirebase button from this codebase to your view

  1. Now when users click on the button, it will sign them into Firebase using sign in with Apple

Gotchas

  • You need a GoogleService-Info.plist file to compile this codebase. Go through the setup process on Firebase
  • You also need to have Cocopods and run pod install

Tutorials/code used

About

A SwiftUI component which handles logging in with Apple to Firebase

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published