Skip to content

Commit 57cbb96

Browse files
[google_sign_in] Update to GoogleSignIn-iOS 9 (#9655)
Updates the dependency on the GoogleSignIn iOS SDK to the recently released 9.0. Some specific benefits include: - Allows wiring up the nonce parameter on iOS, which was plumbed most of the way through already since the PR had landed upstream when nonce was added to `google_sign_in`, but not fully connected since it wasn't released. - Avoids transitive dependency conflicts with plugins that use AppAuth 2.x. Fixes flutter/flutter#172453 Finishes flutter/flutter#85439 for iOS ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent ab7891a commit 57cbb96

File tree

6 files changed

+55
-9
lines changed

6 files changed

+55
-9
lines changed

packages/google_sign_in/google_sign_in_ios/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 6.1.0
2+
3+
* Updates to `GoogleSignIn` 9.0.
4+
* Adds support for the `nonce` parameter.
5+
16
## 6.0.1
27

38
* Returns configuration errors as `PlatformException`s in Dart instead of

packages/google_sign_in/google_sign_in_ios/darwin/Tests/GoogleSignInTests.m

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ - (void)testSignIn {
263263
[self configureMock:[self.mockSignIn expect]
264264
forSignInWithHint:nil
265265
additionalScopes:@[]
266+
nonce:nil
266267
completion:[OCMArg invokeBlockWithArgs:mockSignInResult, [NSNull null], nil]];
267268

268269
XCTestExpectation *expectation = [self expectationWithDescription:@"completion called"];
@@ -290,6 +291,7 @@ - (void)testSignInWithScopeHint {
290291
serverClientId:nil
291292
hostedDomain:nil]
292293
error:&initializationError];
294+
XCTAssertNil(initializationError);
293295

294296
id mockUser = OCMClassMock([GIDGoogleUser class]);
295297
OCMStub([mockUser userID]).andReturn(@"mockID");
@@ -302,6 +304,7 @@ - (void)testSignInWithScopeHint {
302304
additionalScopes:[OCMArg checkWithBlock:^BOOL(NSArray<NSString *> *scopes) {
303305
return [[NSSet setWithArray:scopes] isEqualToSet:[NSSet setWithArray:requestedScopes]];
304306
}]
307+
nonce:nil
305308
completion:[OCMArg invokeBlockWithArgs:mockSignInResult, [NSNull null], nil]];
306309

307310
XCTestExpectation *expectation = [self expectationWithDescription:@"completion called"];
@@ -318,6 +321,40 @@ - (void)testSignInWithScopeHint {
318321
OCMVerifyAll(self.mockSignIn);
319322
}
320323

324+
- (void)testSignInWithNonce {
325+
FlutterError *initializationError;
326+
[self.plugin configureWithParameters:[FSIPlatformConfigurationParams makeWithClientId:nil
327+
serverClientId:nil
328+
hostedDomain:nil]
329+
error:&initializationError];
330+
XCTAssertNil(initializationError);
331+
332+
id mockUser = OCMClassMock([GIDGoogleUser class]);
333+
OCMStub([mockUser userID]).andReturn(@"mockID");
334+
id mockSignInResult = OCMClassMock([GIDSignInResult class]);
335+
OCMStub([mockSignInResult user]).andReturn(mockUser);
336+
337+
NSString *nonce = @"A nonce";
338+
[self configureMock:[self.mockSignIn expect]
339+
forSignInWithHint:nil
340+
additionalScopes:OCMOCK_ANY
341+
nonce:nonce
342+
completion:[OCMArg invokeBlockWithArgs:mockSignInResult, [NSNull null], nil]];
343+
344+
XCTestExpectation *expectation = [self expectationWithDescription:@"completion called"];
345+
[self.plugin signInWithScopeHint:@[]
346+
nonce:nonce
347+
completion:^(FSISignInResult *result, FlutterError *error) {
348+
XCTAssertNil(error);
349+
XCTAssertNil(result.error);
350+
XCTAssertEqualObjects(result.success.user.userId, @"mockID");
351+
[expectation fulfill];
352+
}];
353+
[self waitForExpectationsWithTimeout:5.0 handler:nil];
354+
355+
OCMVerifyAll(self.mockSignIn);
356+
}
357+
321358
- (void)testSignInAlreadyGranted {
322359
id mockUser = OCMClassMock([GIDGoogleUser class]);
323360
OCMStub([mockUser userID]).andReturn(@"mockID");
@@ -327,6 +364,7 @@ - (void)testSignInAlreadyGranted {
327364
[self configureMock:[self.mockSignIn stub]
328365
forSignInWithHint:nil
329366
additionalScopes:OCMOCK_ANY
367+
nonce:nil
330368
completion:[OCMArg invokeBlockWithArgs:mockSignInResult, [NSNull null], nil]];
331369

332370
NSError *sdkError = [NSError errorWithDomain:kGIDSignInErrorDomain
@@ -355,6 +393,7 @@ - (void)testSignInError {
355393
[self configureMock:[self.mockSignIn stub]
356394
forSignInWithHint:nil
357395
additionalScopes:OCMOCK_ANY
396+
nonce:nil
358397
completion:[OCMArg invokeBlockWithArgs:[NSNull null], sdkError, nil]];
359398

360399
XCTestExpectation *expectation = [self expectationWithDescription:@"completion called"];
@@ -375,6 +414,7 @@ - (void)testSignInExceptionReturnsError {
375414
OCMExpect([self configureMock:self.mockSignIn
376415
forSignInWithHint:OCMOCK_ANY
377416
additionalScopes:OCMOCK_ANY
417+
nonce:nil
378418
completion:OCMOCK_ANY])
379419
.andThrow([NSException exceptionWithName:@"MockName" reason:@"MockReason" userInfo:nil]);
380420

@@ -642,17 +682,20 @@ - (void)configureMock:(id)mock
642682
- (void)configureMock:(id)mock
643683
forSignInWithHint:(NSString *)hint
644684
additionalScopes:(NSArray<NSString *> *)additionalScopes
685+
nonce:(nullable NSString *)nonce
645686
completion:(nullable void (^)(GIDSignInResult *_Nullable signInResult,
646687
NSError *_Nullable error))completion {
647688
#if TARGET_OS_OSX
648689
[mock signInWithPresentingWindow:OCMOCK_ANY
649690
hint:hint
650691
additionalScopes:additionalScopes
692+
nonce:nonce
651693
completion:completion];
652694
#else
653695
[mock signInWithPresentingViewController:[OCMArg isKindOfClass:[FlutterViewController class]]
654696
hint:hint
655697
additionalScopes:additionalScopes
698+
nonce:nonce
656699
completion:completion];
657700
#endif
658701
}

packages/google_sign_in/google_sign_in_ios/darwin/google_sign_in_ios.podspec

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ Enables Google Sign-In in Flutter apps.
1616
s.public_header_files = 'google_sign_in_ios/Sources/google_sign_in_ios/include/**/*.h'
1717
s.module_map = 'google_sign_in_ios/Sources/google_sign_in_ios/include/FLTGoogleSignInPlugin.modulemap'
1818

19-
# AppAuth and GTMSessionFetcher are GoogleSignIn transitive dependencies.
20-
# Depend on versions which defines modules.
21-
s.dependency 'AppAuth', '>= 1.7.4'
19+
# GTMSessionFetcher is a GoogleSignIn transitive dependency, added here as a
20+
# direct dependency to ensure a version which defines modules.
2221
s.dependency 'GTMSessionFetcher', '>= 3.4.0'
23-
s.dependency 'GoogleSignIn', '~> 8.0'
22+
s.dependency 'GoogleSignIn', '~> 9.0'
2423
s.static_framework = true
2524
s.ios.dependency 'Flutter'
2625
s.osx.dependency 'FlutterMacOS'

packages/google_sign_in/google_sign_in_ios/darwin/google_sign_in_ios/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ let package = Package(
1818
dependencies: [
1919
.package(
2020
url: "https://github.com/google/GoogleSignIn-iOS.git",
21-
from: "8.0.0")
21+
from: "9.0.0")
2222
],
2323
targets: [
2424
.target(

packages/google_sign_in/google_sign_in_ios/darwin/google_sign_in_ios/Sources/google_sign_in_ios/FLTGoogleSignInPlugin.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,18 +276,17 @@ - (void)signInWithHint:(nullable NSString *)hint
276276
nonce:(nullable NSString *)nonce
277277
completion:(void (^)(GIDSignInResult *_Nullable signInResult,
278278
NSError *_Nullable error))completion {
279-
// TODO(stuartmorgan): Add the nonce parameter to the calls below once it's available; it was
280-
// added after 8.0, and based on https://github.com/google/GoogleSignIn-iOS/releases appears to
281-
// be slated for an 8.1 release. See https://github.com/flutter/flutter/issues/85439.
282279
#if TARGET_OS_OSX
283280
[self.signIn signInWithPresentingWindow:self.registrar.view.window
284281
hint:hint
285282
additionalScopes:additionalScopes
283+
nonce:nonce
286284
completion:completion];
287285
#else
288286
[self.signIn signInWithPresentingViewController:[self topViewController]
289287
hint:hint
290288
additionalScopes:additionalScopes
289+
nonce:nonce
291290
completion:completion];
292291
#endif
293292
}

packages/google_sign_in/google_sign_in_ios/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: google_sign_in_ios
22
description: iOS implementation of the google_sign_in plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_ios
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
5-
version: 6.0.1
5+
version: 6.1.0
66

77
environment:
88
sdk: ^3.6.0

0 commit comments

Comments
 (0)