Skip to content

Commit a64e51a

Browse files
[google_sign_in] Convert the iOS example app and UI tests to Swift (flutter#13271)
Converts the `google_sign_in_ios` iOS example runner and XCUITests from Objective-C to Swift. The plugin itself was already Swift-only after the earlier migration PRs. GID URL schemes, `Info.plist` keys, and the existing `RunnerTests` target (shared `darwin/Tests`) are unchanged. `Runner-Bridging-Header.h` is required so the Swift `AppDelegate` can import Flutter's generated Objective-C `GeneratedPluginRegistrant`, matching `url_launcher_ios` and the app-facing `google_sign_in` example. Bumps `google_sign_in_ios` to **6.3.8**. This is leftover example/UI-test work from the Obj-C → Swift migration. Completes flutter#119103 for the iOS example app. Existing XCUITests were ported from Objective-C to Swift; no new behavior. ## 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 93baed9 commit a64e51a

9 files changed

Lines changed: 94 additions & 117 deletions

File tree

‎packages/google_sign_in/google_sign_in_ios/CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 6.3.9
2+
3+
* Converts the iOS example app and UI tests to Swift.
4+
15
## 6.3.8
26

37
* Removes the public iOS `handleOpen` helper. On macOS `handleOpen` remains public because it implements `FlutterAppLifecycleDelegate`.

‎packages/google_sign_in/google_sign_in_ios/example/ios/Runner.xcodeproj/project.pbxproj‎

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; };
1212
78A36DA12AF5761E00CBFD43 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7A303C2D1E89D76400B1F19E /* GoogleService-Info.plist */; };
1313
7ACDFB0E1E8944C400BE2D00 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7ACDFB0D1E8944C400BE2D00 /* AppFrameworkInfo.plist */; };
14-
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
15-
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
14+
978B8F6F1D3862AE00F588F7 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.swift */; };
1615
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
1716
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
1817
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
1918
F76AC1A52666D0540040C8BC /* GoogleSignInTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76AC1A42666D0540040C8BC /* GoogleSignInTests.swift */; };
20-
F76AC1B32666D0610040C8BC /* GoogleSignInUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = F76AC1B22666D0610040C8BC /* GoogleSignInUITests.m */; };
19+
F76AC1B32666D0610040C8BC /* GoogleSignInUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76AC1B22666D0610040C8BC /* GoogleSignInUITests.swift */; };
2120
/* End PBXBuildFile section */
2221

2322
/* Begin PBXContainerItemProxy section */
@@ -59,12 +58,11 @@
5958
7A303C2D1E89D76400B1F19E /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "../../darwin/Tests/GoogleService-Info.plist"; sourceTree = SOURCE_ROOT; };
6059
7ACDFB0D1E8944C400BE2D00 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
6160
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
62-
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
63-
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
61+
7AFFD8ED1D35381100E5BB4D /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
62+
7AFFD8EE1D35381100E5BB4D /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
6463
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
6564
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
6665
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
67-
97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
6866
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
6967
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
7068
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
@@ -73,7 +71,7 @@
7371
F76AC1A42666D0540040C8BC /* GoogleSignInTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = GoogleSignInTests.swift; path = ../../darwin/Tests/GoogleSignInTests.swift; sourceTree = SOURCE_ROOT; };
7472
F76AC1A62666D0540040C8BC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7573
F76AC1B02666D0610040C8BC /* RunnerUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
76-
F76AC1B22666D0610040C8BC /* GoogleSignInUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GoogleSignInUITests.m; sourceTree = "<group>"; };
74+
F76AC1B22666D0610040C8BC /* GoogleSignInUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoogleSignInUITests.swift; sourceTree = "<group>"; };
7775
F76AC1B42666D0610040C8BC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7876
/* End PBXFileReference section */
7977

@@ -143,25 +141,16 @@
143141
children = (
144142
5C6F5A6C1EC3B4CB008D64B5 /* GeneratedPluginRegistrant.h */,
145143
5C6F5A6D1EC3B4CB008D64B5 /* GeneratedPluginRegistrant.m */,
146-
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */,
147-
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */,
144+
7AFFD8EE1D35381100E5BB4D /* AppDelegate.swift */,
145+
7AFFD8ED1D35381100E5BB4D /* Runner-Bridging-Header.h */,
148146
97C146FA1CF9000F007C117D /* Main.storyboard */,
149147
97C146FD1CF9000F007C117D /* Assets.xcassets */,
150148
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
151149
97C147021CF9000F007C117D /* Info.plist */,
152-
97C146F11CF9000F007C117D /* Supporting Files */,
153150
);
154151
path = Runner;
155152
sourceTree = "<group>";
156153
};
157-
97C146F11CF9000F007C117D /* Supporting Files */ = {
158-
isa = PBXGroup;
159-
children = (
160-
97C146F21CF9000F007C117D /* main.m */,
161-
);
162-
name = "Supporting Files";
163-
sourceTree = "<group>";
164-
};
165154
F76AC1A32666D0540040C8BC /* RunnerTests */ = {
166155
isa = PBXGroup;
167156
children = (
@@ -175,7 +164,7 @@
175164
F76AC1B12666D0610040C8BC /* RunnerUITests */ = {
176165
isa = PBXGroup;
177166
children = (
178-
F76AC1B22666D0610040C8BC /* GoogleSignInUITests.m */,
167+
F76AC1B22666D0610040C8BC /* GoogleSignInUITests.swift */,
179168
F76AC1B42666D0610040C8BC /* Info.plist */,
180169
);
181170
path = RunnerUITests;
@@ -254,6 +243,7 @@
254243
TargetAttributes = {
255244
97C146ED1CF9000F007C117D = {
256245
CreatedOnToolsVersion = 7.3.1;
246+
LastSwiftMigration = 1100;
257247
};
258248
F76AC1A12666D0540040C8BC = {
259249
CreatedOnToolsVersion = 12.5;
@@ -358,8 +348,7 @@
358348
isa = PBXSourcesBuildPhase;
359349
buildActionMask = 2147483647;
360350
files = (
361-
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */,
362-
97C146F31CF9000F007C117D /* main.m in Sources */,
351+
978B8F6F1D3862AE00F588F7 /* AppDelegate.swift in Sources */,
363352
5C6F5A6E1EC3B4CB008D64B5 /* GeneratedPluginRegistrant.m in Sources */,
364353
);
365354
runOnlyForDeploymentPostprocessing = 0;
@@ -376,7 +365,7 @@
376365
isa = PBXSourcesBuildPhase;
377366
buildActionMask = 2147483647;
378367
files = (
379-
F76AC1B32666D0610040C8BC /* GoogleSignInUITests.m in Sources */,
368+
F76AC1B32666D0610040C8BC /* GoogleSignInUITests.swift in Sources */,
380369
);
381370
runOnlyForDeploymentPostprocessing = 0;
382371
};
@@ -542,6 +531,8 @@
542531
);
543532
PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.googleSignInExample;
544533
PRODUCT_NAME = "$(TARGET_NAME)";
534+
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
535+
SWIFT_VERSION = 5.0;
545536
};
546537
name = Debug;
547538
};
@@ -566,6 +557,8 @@
566557
);
567558
PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.googleSignInExample;
568559
PRODUCT_NAME = "$(TARGET_NAME)";
560+
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
561+
SWIFT_VERSION = 5.0;
569562
};
570563
name = Release;
571564
};
@@ -617,6 +610,7 @@
617610
);
618611
PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.RunnerUITests;
619612
PRODUCT_NAME = "$(TARGET_NAME)";
613+
SWIFT_VERSION = 5.0;
620614
TEST_TARGET_NAME = Runner;
621615
};
622616
name = Debug;
@@ -633,6 +627,7 @@
633627
);
634628
PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.RunnerUITests;
635629
PRODUCT_NAME = "$(TARGET_NAME)";
630+
SWIFT_VERSION = 5.0;
636631
TEST_TARGET_NAME = Runner;
637632
};
638633
name = Release;

‎packages/google_sign_in/google_sign_in_ios/example/ios/Runner/AppDelegate.m‎

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2013 The Flutter Authors
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import Flutter
6+
import UIKit
7+
8+
@main
9+
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
10+
override func application(
11+
_ application: UIApplication,
12+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
13+
) -> Bool {
14+
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
15+
}
16+
17+
func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
18+
GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
19+
}
20+
}

packages/google_sign_in/google_sign_in_ios/example/ios/Runner/AppDelegate.h renamed to packages/google_sign_in/google_sign_in_ios/example/ios/Runner/Runner-Bridging-Header.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,4 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#import <Flutter/Flutter.h>
6-
#import <UIKit/UIKit.h>
7-
8-
@interface AppDelegate : FlutterAppDelegate <FlutterImplicitEngineDelegate>
9-
10-
@end
5+
#import "GeneratedPluginRegistrant.h"

‎packages/google_sign_in/google_sign_in_ios/example/ios/Runner/main.m‎

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎packages/google_sign_in/google_sign_in_ios/example/ios/RunnerUITests/GoogleSignInUITests.m‎

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2013 The Flutter Authors
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import XCTest
6+
import os
7+
8+
class GoogleSignInUITests: XCTestCase {
9+
var app: XCUIApplication!
10+
11+
override func setUp() {
12+
continueAfterFailure = false
13+
14+
app = XCUIApplication()
15+
app.launch()
16+
}
17+
18+
func testSignInPopUp() throws {
19+
let app = try XCTUnwrap(self.app)
20+
21+
let signInButton = app.buttons["SIGN IN"]
22+
if !signInButton.waitForExistence(timeout: 30.0) {
23+
os_log(.error, "%{public}@", app.debugDescription)
24+
XCTFail("Failed due to not able to find Sign In button")
25+
}
26+
signInButton.tap()
27+
28+
allowSignInPermissions()
29+
}
30+
31+
func allowSignInPermissions() {
32+
// The "Sign In" system permissions pop up isn't caught by
33+
// addUIInterruptionMonitorWithDescription.
34+
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
35+
let permissionAlert = springboard.alerts.firstMatch
36+
if permissionAlert.waitForExistence(timeout: 5.0) {
37+
// The alert is titled in the simulator's language, so the confirmation
38+
// button can't be looked up by name. It is the last of the alert's two
39+
// buttons ("Cancel" and "Continue") in every localization.
40+
let alertButtons = permissionAlert.buttons
41+
let buttonCount = alertButtons.count
42+
guard buttonCount > 0 else {
43+
XCTFail("Sign In permission alert has no buttons")
44+
return
45+
}
46+
alertButtons.element(boundBy: buttonCount - 1).tap()
47+
} else {
48+
os_log("Permission alert not detected, continuing.")
49+
}
50+
}
51+
}

‎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.3.8
5+
version: 6.3.9
66

77
environment:
88
sdk: ^3.11.0

0 commit comments

Comments
 (0)