FirebaseAuthEasier is a Swift package that makes it easy to integrate Firebase Authentication (Apple/Google sign-in) into SwiftUI apps.

- Provides Apple, Google, and Anonymous sign-in UI/logic in one package
- Simple API with customizable UI components
- Built on top of official Firebase/GoogleSignIn SDKs
- Supports iOS 15 and later
- Flexible authentication operation APIs via FirebaseAuthService
- SignInButton components can be used individually with flexible UI customization
- iOS 15.0+
- firebase-ios-sdk (v11.13.0+)
- GoogleSignIn-iOS (v8.0.0+)
Add the package using Swift Package Manager.
.package(url: "https://github.com/sugijotaro/FirebaseAuthEasier.git", from: "1.0.0")
In Xcode:
- Go to "File" → "Add Package Dependencies..." and enter the URL above
- Select "FirebaseAuthEasier" to add
- Follow the Firebase official documentation to add GoogleService-Info.plist
- Initialize Firebase in your
AppDelegate
or@main
App - Enable "Sign in with Apple", "Sign in with Google", and "Anonymous" in Firebase Console
- Add "Sign in with Apple" capability in Xcode project settings
- For Google authentication, obtain OAuth client ID from Google Cloud Console and configure it in your Firebase project
For more detailed setup instructions, see this article (Japanese only)
import SwiftUI
import FirebaseAuthEasier
struct ContentView: View {
var body: some View {
FirebaseAuthView()
}
}
A demo app is available in the sample/FirebaseAuthEasierDemoApp
directory.
You can use this app to see FirebaseAuthEasier in action and as a reference for integration.
FirebaseAuthView
can be flexibly customized with the following initializer parameters:
public init(
providers: [SignInProviderType]? = nil,
labelType: SignInButtonLabelType = .signIn,
termsOfServiceURL: URL? = nil,
privacyPolicyURL: URL? = nil,
onSignInStart: ((SignInProviderType) -> Void)? = nil,
didSignIn: ((Result<AuthDataResult, Error>) -> Void)? = nil,
@ViewBuilder content: @escaping () -> Content = { FirebaseAuthDefaultContentView() }
)
Specify which sign-in providers to display.
FirebaseAuthView(providers: [.apple]) // Apple sign-in only
FirebaseAuthView(providers: [.apple, .google, .anonymous]) // All providers including anonymous
Specify the button label type (.signIn, .signUp, .continue).
FirebaseAuthView(labelType: .signUp)
URL for Terms of Service. If provided, a legal message will be displayed at the bottom of the sign-in screen.
FirebaseAuthView(termsOfServiceURL: URL(string: "https://example.com/terms"))
URL for Privacy Policy. If provided, a legal message will be displayed at the bottom of the sign-in screen.
FirebaseAuthView(privacyPolicyURL: URL(string: "https://example.com/privacy"))
Customize the view displayed at the top of the sign-in screen.
FirebaseAuthView {
VStack {
Text("Welcome!")
Image(systemName: "person.circle")
}
}
Closure called when sign-in process starts. Receives the provider type.
FirebaseAuthView(onSignInStart: { provider in
print("Sign-in started: \(provider)")
})
Closure called when sign-in completes. Receives success/failure result.
FirebaseAuthView(didSignIn: { result in
switch result {
case .success(let authData):
// Handle successful sign-in
case .failure(let error):
// Handle error
}
})
struct ContentView: View {
var body: some View {
FirebaseAuthView(
providers: [.apple, .google, .anonymous],
labelType: .continue,
termsOfServiceURL: URL(string: "https://example.com/terms")!,
privacyPolicyURL: URL(string: "https://example.com/privacy")!,
onSignInStart: { provider in
print("Sign-in started with provider: \(provider)")
},
didSignIn: { result in
switch result {
case .success(let authResult):
if authResult.user.isAnonymous {
print("Anonymous sign-in successful")
} else {
print("Sign-in successful")
}
case .failure(let error):
print("Sign-in failed: \(error.localizedDescription)")
}
}
) {
VStack {
Image(systemName: "person.circle")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Welcome!")
}
}
}
}
FirebaseAuthService
provides convenient APIs for detailed authentication operations such as sign-in, sign-out, anonymous authentication, re-authentication, and account deletion.
import FirebaseAuthEasier
let authService = FirebaseAuthService()
// Anonymous sign-in
authService.signInAnonymously { result in /* ... */ }
// Sign-out
authService.signOut { result in /* ... */ }
// Link authentication providers
// Account deletion
// ...and more
SignInButton
provides Apple/Google sign-in button UI that can be used individually, with fine-grained customization for colors, labels, corner radius, borders, and more.
import SwiftUI
import FirebaseAuthEasier
SignInButton(
provider: .apple,
buttonStyle: .black,
labelStyle: .titleAndIcon,
labelType: .signIn,
cornerStyle: .radius(12),
hasBorder: true
) {
// Button tap handling
}
We welcome contributions to this project!
- Report bugs or request features via Issues
- Pull requests are very welcome
- Feel free to reach out with improvement suggestions or feedback
- Authentication will fail if Firebase/GoogleSignIn setup is not configured correctly
- Google authentication requires configuration in Google Cloud Console
- Apple sign-in only works on physical devices
- When using Apple sign-in, make sure to enable it in Firebase Console and add the capability in Xcode
MIT © Jotaro Sugiyama