Implementing UIKit Sign in with Apple to be used in SwiftUI
In this recipe, you'll learn how to use Sign in with Apple in a SwiftUI app by wrapping the UIKit component.
In iOS 14, SwiftUI provides a native SignInWithApple
button, but if you don't have support for it yet and are still using iOS 13, then don't worry – in this recipe, we are going to implement a wrapper around the UIKit class that works very well with SwiftUI.
Here, we are going to implement a simple app that permits us to log in using our Apple ID and presents our credentials when we are logged in.
Important Note
Sign in with Apple is still a bit flaky when it's run in a simulator, so it is safer to run this recipe on an iOS device.
The app that we'll be implementing in this recipe is simple, but it can be a good foundation to implement a proper app with Apple's authentication.
As you may recall, the AuthenticationServices
framework only passes the user's...