Testing Apple Sign-In Framework
Back in October 2019, I was assigned the task of implementing Apple Sign-in, a new single sign-on solution released by Apple as part of the release of iOS 13. It wasn’t too complicated to implement. Although, testing this framework certainly comes with its own set of challenges. Let’s take a look at how I implemented it. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 class AppleSignInAuthenticationWrapper: NSObject { weak var delegate: AppleSignInAuthenticationDelegate? func signIn() { let provider = ASAuthorizationAppleIDProvider() let request = provider.createRequest() request.requestedScopes = [.fullName, .email] let controller = ASAuthorizationController(authorizationRequests: [request]) controller.delegate = self controller.presentationContextProvider = self controller.performRequests() } } In one single method call, we initialise the provider, create the request, inject the request into the controller and then call the performRequests method against the controller. That’s a lot of creation for one single method. ...