Skip to content

Commit 72c947c

Browse files
authored
[google_sign_in_ios] Upgrade GoogleSignIn iOS SDK to 7.0 (flutter#5240)
Fixes flutter#137140. See https://developers.google.com/identity/sign-in/ios/quick-migration-guide and https://developers.google.com/identity/sign-in/ios/release for info about changes made to the SDK.
1 parent be18d28 commit 72c947c

25 files changed

+420
-308
lines changed

packages/google_sign_in/google_sign_in/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 6.1.6
2+
3+
* Updates README to direct to google_sign_in_ios README for iOS integration instructions.
4+
15
## 6.1.5
26

37
* Adds pub topics to package metadata.

packages/google_sign_in/google_sign_in/README.md

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -27,59 +27,7 @@ Otherwise, you may encounter `APIException` errors.
2727

2828
### iOS integration
2929

30-
1. [First register your application](https://firebase.google.com/docs/ios/setup).
31-
2. Make sure the file you download in step 1 is named
32-
`GoogleService-Info.plist`.
33-
3. Move or copy `GoogleService-Info.plist` into the `[my_project]/ios/Runner`
34-
directory.
35-
4. Open Xcode, then right-click on `Runner` directory and select
36-
`Add Files to "Runner"`.
37-
5. Select `GoogleService-Info.plist` from the file manager.
38-
6. A dialog will show up and ask you to select the targets, select the `Runner`
39-
target.
40-
7. If you need to authenticate to a backend server you can add a
41-
`SERVER_CLIENT_ID` key value pair in your `GoogleService-Info.plist`.
42-
```xml
43-
<key>SERVER_CLIENT_ID</key>
44-
<string>[YOUR SERVER CLIENT ID]</string>
45-
```
46-
8. Then add the `CFBundleURLTypes` attributes below into the
47-
`[my_project]/ios/Runner/Info.plist` file.
48-
49-
```xml
50-
<!-- Put me in the [my_project]/ios/Runner/Info.plist file -->
51-
<!-- Google Sign-in Section -->
52-
<key>CFBundleURLTypes</key>
53-
<array>
54-
<dict>
55-
<key>CFBundleTypeRole</key>
56-
<string>Editor</string>
57-
<key>CFBundleURLSchemes</key>
58-
<array>
59-
<!-- TODO Replace this value: -->
60-
<!-- Copied from GoogleService-Info.plist key REVERSED_CLIENT_ID -->
61-
<string>com.googleusercontent.apps.861823949799-vc35cprkp249096uujjn0vvnmcvjppkn</string>
62-
</array>
63-
</dict>
64-
</array>
65-
<!-- End of the Google Sign-in Section -->
66-
```
67-
68-
As an alternative to adding `GoogleService-Info.plist` to your Xcode project,
69-
you can instead configure your app in Dart code. In this case, skip steps 3 to 7
70-
and pass `clientId` and `serverClientId` to the `GoogleSignIn` constructor:
71-
72-
```dart
73-
GoogleSignIn _googleSignIn = GoogleSignIn(
74-
...
75-
// The OAuth client id of your app. This is required.
76-
clientId: ...,
77-
// If you need to authenticate to a backend server, specify its OAuth client. This is optional.
78-
serverClientId: ...,
79-
);
80-
```
81-
82-
Note that step 8 is still required.
30+
Please see [instructions on integrating Google Sign-In for iOS](https://pub.dev/packages/google_sign_in_ios#ios-integration).
8331

8432
#### iOS additional requirement
8533

@@ -212,12 +160,12 @@ For more details, take a look at the
212160

213161
### Does an app always need to check `canAccessScopes`?
214162

215-
The new web SDK implicitly grant access to the `email`, `profile` and `openid`
163+
The new web SDK implicitly grant access to the `email`, `profile` and `openid`
216164
scopes when users complete the sign-in process (either via the One Tap UX or the
217165
Google Sign In button).
218166

219167
If an app only needs an `idToken`, or only requests permissions to any/all of
220-
the three scopes mentioned above
168+
the three scopes mentioned above
221169
([OpenID Connect scopes](https://developers.google.com/identity/protocols/oauth2/scopes#openid-connect)),
222170
it won't need to implement any additional scope handling.
223171

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
/* Begin PBXBuildFile section */
1010
5C6F5A6E1EC3B4CB008D64B5 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 5C6F5A6D1EC3B4CB008D64B5 /* GeneratedPluginRegistrant.m */; };
11-
7A303C2E1E89D76400B1F19E /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7A303C2D1E89D76400B1F19E /* GoogleService-Info.plist */; };
1211
7ACDFB0E1E8944C400BE2D00 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7ACDFB0D1E8944C400BE2D00 /* AppFrameworkInfo.plist */; };
1312
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
1413
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
@@ -39,7 +38,6 @@
3938
5A76713E622F06379AEDEBFA /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
4039
5C6F5A6C1EC3B4CB008D64B5 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
4140
5C6F5A6D1EC3B4CB008D64B5 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
42-
7A303C2D1E89D76400B1F19E /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
4341
7ACDFB0D1E8944C400BE2D00 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
4442
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
4543
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@@ -118,7 +116,6 @@
118116
97C146FA1CF9000F007C117D /* Main.storyboard */,
119117
97C146FD1CF9000F007C117D /* Assets.xcassets */,
120118
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
121-
7A303C2D1E89D76400B1F19E /* GoogleService-Info.plist */,
122119
97C147021CF9000F007C117D /* Info.plist */,
123120
97C146F11CF9000F007C117D /* Supporting Files */,
124121
);
@@ -173,7 +170,7 @@
173170
97C146E61CF9000F007C117D /* Project object */ = {
174171
isa = PBXProject;
175172
attributes = {
176-
LastUpgradeCheck = 1300;
173+
LastUpgradeCheck = 1430;
177174
ORGANIZATIONNAME = "The Flutter Authors";
178175
TargetAttributes = {
179176
97C146ED1CF9000F007C117D = {
@@ -204,7 +201,6 @@
204201
isa = PBXResourcesBuildPhase;
205202
buildActionMask = 2147483647;
206203
files = (
207-
7A303C2E1E89D76400B1F19E /* GoogleService-Info.plist in Resources */,
208204
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
209205
7ACDFB0E1E8944C400BE2D00 /* AppFrameworkInfo.plist in Resources */,
210206
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,

packages/google_sign_in/google_sign_in/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1300"
3+
LastUpgradeVersion = "1430"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

packages/google_sign_in/google_sign_in/example/ios/Runner/Info.plist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,9 @@
6060
<true/>
6161
<key>UIApplicationSupportsIndirectInputEvents</key>
6262
<true/>
63+
<key>GIDClientID</key>
64+
<string>479882132969-9i9aqik3jfjd7qhci1nqf0bm2g71rm1u.apps.googleusercontent.com</string>
65+
<key>GIDServerClientID</key>
66+
<string>YOUR_SERVER_CLIENT_ID</string>
6367
</dict>
6468
</plist>

packages/google_sign_in/google_sign_in/pubspec.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Flutter plugin for Google Sign-In, a secure authentication system
33
for signing in with a Google account on Android and iOS.
44
repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in
55
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
6-
version: 6.1.5
6+
version: 6.1.6
77

88
environment:
99
sdk: ">=2.19.0 <4.0.0"
@@ -43,5 +43,6 @@ topics:
4343
# The example deliberately includes limited-use secrets.
4444
false_secrets:
4545
- /example/android/app/google-services.json
46-
- /example/ios/Runner/GoogleService-Info.plist
46+
- /example/ios/Runner/Info.plist
47+
- /example/ios/RunnerTests/GoogleService-Info.plist
4748
- /example/ios/RunnerTests/GoogleSignInTests.m

packages/google_sign_in/google_sign_in/test/google_sign_in_test.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,28 @@ void main() {
8181
verify(mockPlatform.signIn());
8282
});
8383

84+
test(
85+
'clientId and serverClientId parameters is forwarded to implementation',
86+
() async {
87+
// #docregion GoogleSignIn
88+
final GoogleSignIn googleSignIn = GoogleSignIn(
89+
// The OAuth client id of your app. This is required.
90+
clientId: 'Your Client ID',
91+
// If you need to authenticate to a backend server, specify its OAuth client. This is optional.
92+
serverClientId: 'Your Server ID',
93+
);
94+
// #enddocregion GoogleSignIn
95+
96+
await googleSignIn.signIn();
97+
98+
_verifyInit(
99+
mockPlatform,
100+
clientId: 'Your Client ID',
101+
serverClientId: 'Your Server ID',
102+
);
103+
verify(mockPlatform.signIn());
104+
});
105+
84106
test('forceCodeForRefreshToken sent with init method call', () async {
85107
final GoogleSignIn googleSignIn =
86108
GoogleSignIn(forceCodeForRefreshToken: true);

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+
## 5.6.5
2+
3+
* Upgrades GoogleSignIn iOS SDK to 7.0.
4+
15
## 5.6.4
26

37
* Converts platform communication to Pigeon.

packages/google_sign_in/google_sign_in_ios/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,62 @@ should add it to your `pubspec.yaml` as usual.
1313

1414
[1]: https://pub.dev/packages/google_sign_in
1515
[2]: https://flutter.dev/docs/development/packages-and-plugins/developing-packages#endorsed-federated-plugin
16+
17+
### iOS integration
18+
19+
1. [Create a Firebase project](https://firebase.google.com/docs/ios/setup#create-firebase-project)
20+
and [register your application](https://firebase.google.com/docs/ios/setup#register-app).
21+
2. [Enable Google Sign-In for your Firebase project](https://firebase.google.com/docs/auth/ios/google-signin#enable_google_sign-in_for_your_firebase_project).
22+
3. Make sure to download a new copy of your project's
23+
`GoogleService-Info.plist` from step 2. Do not put this file in your project.
24+
4. Add the client ID from the `GoogleService-Info.plist` into your app's
25+
`[my_project]/ios/Runner/Info.plist` file.
26+
```xml
27+
<key>GIDClientID</key>
28+
<!-- TODO Replace this value: -->
29+
<!-- Copied from GoogleService-Info.plist key CLIENT_ID -->
30+
<string>[YOUR IOS CLIENT ID]</string>
31+
```
32+
5. If you need to authenticate to a backend server you can add a
33+
`GIDServerClientID` key value pair in your `[my_project]/ios/Runner/Info.plist` file.
34+
```xml
35+
<key>GIDServerClientID</key>
36+
<string>[YOUR SERVER CLIENT ID]</string>
37+
```
38+
6. Then add the `CFBundleURLTypes` attributes below into the
39+
`[my_project]/ios/Runner/Info.plist` file.
40+
41+
```xml
42+
<!-- Put me in the [my_project]/ios/Runner/Info.plist file -->
43+
<!-- Google Sign-in Section -->
44+
<key>CFBundleURLTypes</key>
45+
<array>
46+
<dict>
47+
<key>CFBundleTypeRole</key>
48+
<string>Editor</string>
49+
<key>CFBundleURLSchemes</key>
50+
<array>
51+
<!-- TODO Replace this value: -->
52+
<!-- Copied from GoogleService-Info.plist key REVERSED_CLIENT_ID -->
53+
<string>com.googleusercontent.apps.861823949799-vc35cprkp249096uujjn0vvnmcvjppkn</string>
54+
</array>
55+
</dict>
56+
</array>
57+
<!-- End of the Google Sign-in Section -->
58+
```
59+
60+
As an alternative to editing the `Info.plist` in your Xcode project,
61+
you can instead configure your app in Dart code. In this case, skip steps 4 to 5
62+
and pass `clientId` and `serverClientId` to the `GoogleSignIn` constructor:
63+
64+
<?code-excerpt "../google_sign_in/test/google_sign_in_test.dart (GoogleSignIn)"?>
65+
```dart
66+
final GoogleSignIn googleSignIn = GoogleSignIn(
67+
// The OAuth client id of your app. This is required.
68+
clientId: 'Your Client ID',
69+
// If you need to authenticate to a backend server, specify its OAuth client. This is optional.
70+
serverClientId: 'Your Server ID',
71+
);
72+
```
73+
74+
Note that step 6 is still required.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
5C6F5A6E1EC3B4CB008D64B5 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 5C6F5A6D1EC3B4CB008D64B5 /* GeneratedPluginRegistrant.m */; };
11-
7A303C2E1E89D76400B1F19E /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7A303C2D1E89D76400B1F19E /* GoogleService-Info.plist */; };
11+
78A36DA12AF5761E00CBFD43 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7A303C2D1E89D76400B1F19E /* GoogleService-Info.plist */; };
1212
7ACDFB0E1E8944C400BE2D00 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7ACDFB0D1E8944C400BE2D00 /* AppFrameworkInfo.plist */; };
1313
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
1414
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
@@ -163,7 +163,6 @@
163163
97C146FA1CF9000F007C117D /* Main.storyboard */,
164164
97C146FD1CF9000F007C117D /* Assets.xcassets */,
165165
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
166-
7A303C2D1E89D76400B1F19E /* GoogleService-Info.plist */,
167166
97C147021CF9000F007C117D /* Info.plist */,
168167
97C146F11CF9000F007C117D /* Supporting Files */,
169168
);
@@ -191,6 +190,7 @@
191190
isa = PBXGroup;
192191
children = (
193192
F76AC1A42666D0540040C8BC /* GoogleSignInTests.m */,
193+
7A303C2D1E89D76400B1F19E /* GoogleService-Info.plist */,
194194
F76AC1A62666D0540040C8BC /* Info.plist */,
195195
);
196196
path = RunnerTests;
@@ -316,7 +316,6 @@
316316
isa = PBXResourcesBuildPhase;
317317
buildActionMask = 2147483647;
318318
files = (
319-
7A303C2E1E89D76400B1F19E /* GoogleService-Info.plist in Resources */,
320319
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
321320
7ACDFB0E1E8944C400BE2D00 /* AppFrameworkInfo.plist in Resources */,
322321
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
@@ -328,6 +327,7 @@
328327
isa = PBXResourcesBuildPhase;
329328
buildActionMask = 2147483647;
330329
files = (
330+
78A36DA12AF5761E00CBFD43 /* GoogleService-Info.plist in Resources */,
331331
);
332332
runOnlyForDeploymentPostprocessing = 0;
333333
};

packages/google_sign_in/google_sign_in_ios/example/ios/Runner/GoogleService-Info.plist

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

packages/google_sign_in/google_sign_in_ios/example/ios/Runner/Info.plist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,9 @@
6060
<true/>
6161
<key>UIApplicationSupportsIndirectInputEvents</key>
6262
<true/>
63+
<key>GIDClientID</key>
64+
<string>479882132969-9i9aqik3jfjd7qhci1nqf0bm2g71rm1u.apps.googleusercontent.com</string>
65+
<key>GIDServerClientID</key>
66+
<string>YOUR_SERVER_CLIENT_ID</string>
6367
</dict>
6468
</plist>

0 commit comments

Comments
 (0)