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 —
Please visit the official Google documentation website and follow the initial steps to set-up your project to use Google Auth.
Please visit this page and add the AppDelegate code given as is.
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