From a2b2b344ef5d81b34d8508341013a705e0551ae4 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Thu, 8 May 2025 16:12:44 +0100 Subject: [PATCH 1/5] README for SwiftUI alpha release --- FirebaseSwiftUI/README.md | 138 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 FirebaseSwiftUI/README.md diff --git a/FirebaseSwiftUI/README.md b/FirebaseSwiftUI/README.md new file mode 100644 index 0000000000..2395640441 --- /dev/null +++ b/FirebaseSwiftUI/README.md @@ -0,0 +1,138 @@ +# FirebaseUI for SwiftUI (Alpha release) + +## Installation + +1. Launch Xcode and open the project or workspace where you want to add the packages. +2. In the menu bar, go to: `File > Add Package Dependencies...` +3. Enter the Package URL: `https://github.com/firebase/FirebaseUI-iOS` +4. Select target(s) you wish to add to your app (currently `FirebaseAuthSwiftUI`, `FirebaseGoogleSwiftUI`, `FirebaseFacebookSwiftUI` and `FirebasePhoneAuthSwiftUI` are available). `FirebaseAuthSwiftUI` is required and contains Email provider API. +5. Press `Add Packages` button to complete installation. + + +## Getting started + +1. Follow step 2, 3 & 5 on [adding Firebase to your SwiftUI app](https://firebase.google.com/docs/ios/setup). +2. You should now update your app entry point to look like this: + +```swift +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 + + init() {} + + 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) + } +} +``` + +3. For a more complete example, see the [SwiftUI sample app](https://github.com/firebase/FirebaseUI-iOS/tree/main/samples/swiftui/FirebaseSwiftUIExample). + +## Configuration options + +You can create an `AuthConfiguration` instance and pass it to the `AuthService` as demonstrated above. Here are the options: + +```swift +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 = URL(string: "https://example.com/tos")!, + privacyPolicyUrl: URL = URL(string: "https://example.com/privacy")!, + emailLinkSignInActionCodeSettings: ActionCodeSettings? = nil, + verifyEmailActionCodeSettings: ActionCodeSettings? = nil) +} +``` + +## Configuring providers + +1. Ensure the provider is installed from step 1 (e.g. if configuring Google provider, you need to install `FirebaseGoogleSwiftUI` package). +2. Ensure you have called the relevant API on `AuthService` to initialise provider. Example of Email and Google provider initialization: + +```swift +let authService = AuthService() + .withEmailSignIn() + .withGoogleSignIn() +``` + +> Note: There may be additional setup for each provider typically in the AppDelegate. [See example app for setup.](https://github.com/firebase/FirebaseUI-iOS/tree/main/samples/swiftui/FirebaseSwiftUIExample) + + +## API available for alpha release +1. General API + - Auto upgrade anonymous user account linking (if configured). + - Sign out +2. Email/Password + - Sign-in/Create user + - Password recovery + - Email link sign-in +3. Google + - Sign in with Google +4. Facebook + 1. Sign in with Facebook limited login + 2. Sign in with Facebook classic login +5. Phone Auth + - Verify phone number + - Sign in with phone number +6. User + - Update password + - Delete user + - Verify email address + +## Notes for Alpha release +1. Customization/theming for Views is not yet available. +2. The providers available are Email, Phone, Google and Facebook. +3. 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. +4. The UI has not been polished and is subject to change once design has been finalized. From dc027321c69629299d7f4ccaefbc9575fc93a518 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Thu, 8 May 2025 16:15:36 +0100 Subject: [PATCH 2/5] format --- FirebaseSwiftUI/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FirebaseSwiftUI/README.md b/FirebaseSwiftUI/README.md index 2395640441..f0b006767c 100644 --- a/FirebaseSwiftUI/README.md +++ b/FirebaseSwiftUI/README.md @@ -131,7 +131,8 @@ let authService = AuthService() - Delete user - Verify email address -## Notes for Alpha release + +## Notes for Alpha release 1. Customization/theming for Views is not yet available. 2. The providers available are Email, Phone, Google and Facebook. 3. 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. From 15107ed0db986a7edf3fbe75c6125d5b32306e37 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Thu, 8 May 2025 16:16:26 +0100 Subject: [PATCH 3/5] format --- FirebaseSwiftUI/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FirebaseSwiftUI/README.md b/FirebaseSwiftUI/README.md index f0b006767c..14c1b7f384 100644 --- a/FirebaseSwiftUI/README.md +++ b/FirebaseSwiftUI/README.md @@ -9,7 +9,7 @@ 5. Press `Add Packages` button to complete installation. -## Getting started +## Getting started 1. Follow step 2, 3 & 5 on [adding Firebase to your SwiftUI app](https://firebase.google.com/docs/ios/setup). 2. You should now update your app entry point to look like this: @@ -96,7 +96,7 @@ public struct AuthConfiguration { } ``` -## Configuring providers +## Configuring providers 1. Ensure the provider is installed from step 1 (e.g. if configuring Google provider, you need to install `FirebaseGoogleSwiftUI` package). 2. Ensure you have called the relevant API on `AuthService` to initialise provider. Example of Email and Google provider initialization: From d30af1cbe4e446bfadedc240b33b71658fa8cbf4 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Fri, 9 May 2025 08:04:37 +0100 Subject: [PATCH 4/5] chore: address PR feedback; spelling and formatting code snippet --- FirebaseSwiftUI/README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/FirebaseSwiftUI/README.md b/FirebaseSwiftUI/README.md index 14c1b7f384..deea05b315 100644 --- a/FirebaseSwiftUI/README.md +++ b/FirebaseSwiftUI/README.md @@ -5,8 +5,8 @@ 1. Launch Xcode and open the project or workspace where you want to add the packages. 2. In the menu bar, go to: `File > Add Package Dependencies...` 3. Enter the Package URL: `https://github.com/firebase/FirebaseUI-iOS` -4. Select target(s) you wish to add to your app (currently `FirebaseAuthSwiftUI`, `FirebaseGoogleSwiftUI`, `FirebaseFacebookSwiftUI` and `FirebasePhoneAuthSwiftUI` are available). `FirebaseAuthSwiftUI` is required and contains Email provider API. -5. Press `Add Packages` button to complete installation. +4. Select target(s) you wish to add to your app (currently `FirebaseAuthSwiftUI`, `FirebaseGoogleSwiftUI`, `FirebaseFacebookSwiftUI` and `FirebasePhoneAuthSwiftUI` are available). `FirebaseAuthSwiftUI` is required and contains the Email provider API. +5. Press the `Add Packages` button to complete installation. ## Getting started @@ -33,11 +33,9 @@ class AppDelegate: NSObject, UIApplicationDelegate { struct FirebaseSwiftUIExampleApp: App { @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate - init() {} - var body: some Scene { WindowGroup { - ContentView() + ContentView() } } } From b20de63fa57fa6c2d9f82cfbb1dc8fd8429547ab Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Fri, 9 May 2025 08:09:48 +0100 Subject: [PATCH 5/5] chore: grammar correction --- FirebaseSwiftUI/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FirebaseSwiftUI/README.md b/FirebaseSwiftUI/README.md index deea05b315..4d5c05bd21 100644 --- a/FirebaseSwiftUI/README.md +++ b/FirebaseSwiftUI/README.md @@ -97,7 +97,7 @@ public struct AuthConfiguration { ## Configuring providers 1. Ensure the provider is installed from step 1 (e.g. if configuring Google provider, you need to install `FirebaseGoogleSwiftUI` package). -2. Ensure you have called the relevant API on `AuthService` to initialise provider. Example of Email and Google provider initialization: +2. Ensure you have called the relevant API on `AuthService` to initialise the provider. Example of Email and Google provider initialization: ```swift let authService = AuthService()