Hi everyone,

In this article, I’ll share how to implement “Sign-in with Google” (or some other social login) in a SwiftUI project.

As of now, the social login button and flow is only available for implementation using a view controller in UIKit. Hence, we’ll create SwiftUI views for them using UIViewRepresentable to implement the functionality in our project.

We’re specifically implementing Sign-in with Google, however, the concept remains the same to implement other providers too (eg. Sign-in with GitHub).

Okay, let’s go step-by-step —

1. Install required dependencies and set-up project

Please visit the official Google documentation website and follow the initial steps to set-up your project to use Google Auth.

2. Add the AppDelegate code as-is from documentation

Please visit this page and add the AppDelegate code given as is.

3. Wrap sign-in button and flow for SwiftUI

The above documentation page (that we’ve used in step 2), contains all the steps (four steps) needed from start to finish. Out of these, we’ve already completed the first two steps (till ’Enable Sign-In’).

Step 3 and 4 (‘Add the sign-in button’ and ‘Sign-out user’) in the documentation are both for view controllers. We’ll be covering both of them here by wrapping them to SwiftUI views using UIViewRepresentable.

#social-login #programming #ios #swiftui #sign-in-with-google

Implement Sign-In with Google in a SwiftUI App
16.60 GEEK