Skip to content

Commit 8f8c481

Browse files
authored
Merge branch 'main' into mdmathias/fix-keychainstore-init
2 parents 5e8393a + 55e4132 commit 8f8c481

12 files changed

Lines changed: 209 additions & 49 deletions

File tree

.github/workflows/builds.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
os: [macos-latest]
18+
os: [macos-15]
1919

2020
steps:
2121
- uses: actions/checkout@v3
22+
- name: Select Xcode
23+
run: sudo xcode-select -s /Applications/Xcode_16.4.app/Contents/Developer
2224
- name: Archive for iOS
2325
run: |
2426
xcodebuild \

.github/workflows/integration_tests.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
fi
4848
4949
swift-button-functional-test:
50-
runs-on: macos-latest
50+
runs-on: macos-15
5151
needs: check-pr-body-for-key
5252
# Don't run if triggered by a PR from a fork since our Secrets won't be provided to the runner.
5353
if: ${{ needs.check-pr-body-for-key.outputs.RUN_INTEGRATION == 'yes' && !github.event.pull_request.head.repo.fork }}
@@ -57,14 +57,15 @@ jobs:
5757
steps:
5858
- name: Checkout
5959
uses: actions/checkout@v3
60+
- name: Select Xcode
61+
run: sudo xcode-select -s /Applications/Xcode_16.4.app/Contents/Developer
6062
- name: Build test target for Google Sign-in button for Swift
6163
run: |
6264
xcodebuild \
6365
-project DaysUntilBirthday.xcodeproj \
6466
build-for-testing \
6567
-scheme DaysUntilBirthday\ \(iOS\) \
6668
-sdk iphonesimulator \
67-
-destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4'
6869
- name: Run test target for Google Sign-in button for Swift
6970
env:
7071
EMAIL_SECRET : ${{ secrets.EMAIL_SECRET }}
@@ -75,12 +76,12 @@ jobs:
7576
test-without-building \
7677
-scheme DaysUntilBirthday\ \(iOS\) \
7778
-sdk iphonesimulator \
78-
-destination 'platform=iOS Simulator,name=iPhone 15,OS=17.4' \
79+
-destination 'platform=iOS Simulator,name=iPhone 16,OS=18.6' \
7980
EMAIL_SECRET=$EMAIL_SECRET \
8081
PASSWORD_SECRET=$PASSWORD_SECRET
8182
8283
app-check-api-token-tests:
83-
runs-on: macOS-13
84+
runs-on: macos-15
8485
# Don't run if triggered by a PR from a fork since our Secrets won't be provided to the runner.
8586
if: "!github.event.pull_request.head.repo.fork"
8687
defaults:
@@ -89,17 +90,15 @@ jobs:
8990
steps:
9091
- name: Checkout
9192
uses: actions/checkout@v3
92-
- name: Use Xcode 15.0.1
93-
run: |
94-
sudo xcode-select -s /Applications/Xcode_15.0.1.app
93+
- name: Select Xcode
94+
run: sudo xcode-select -s /Applications/Xcode_16.4.app/Contents/Developer
9595
- name: Build test target for App Check Example
9696
run: |
9797
xcodebuild \
9898
-project AppAttestExample.xcodeproj \
9999
build-for-testing \
100100
-scheme AppAttestExample \
101101
-sdk iphonesimulator \
102-
-destination 'platform=iOS Simulator,name=iPhone 15'
103102
- name: Run test target for App Check Example
104103
env:
105104
AppCheckDebugToken : ${{ secrets.APP_CHECK_DEBUG_TOKEN }}
@@ -110,6 +109,6 @@ jobs:
110109
test-without-building \
111110
-scheme AppAttestExample \
112111
-sdk iphonesimulator \
113-
-destination 'platform=iOS Simulator,name=iPhone 15' \
112+
-destination 'platform=iOS Simulator,name=iPhone 16,OS=18.6' \
114113
AppCheckDebugToken=$AppCheckDebugToken \
115114
APP_CHECK_WEB_API_KEY=$APP_CHECK_WEB_API_KEY

.github/workflows/unit_tests.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,17 @@ jobs:
3939
strategy:
4040
fail-fast: false
4141
matrix:
42-
os: [macos-latest]
42+
os: [macos-15]
4343
sdk: ['macosx', 'iphonesimulator']
4444
include:
4545
- sdk: 'macosx'
4646
destination: '"platform=OS X,arch=x86_64"'
4747
- sdk: 'iphonesimulator'
48-
destination: '"platform=iOS Simulator,name=iPhone 15"'
48+
destination: '"platform=iOS Simulator,name=iPhone 16,OS=18.6"'
4949
steps:
5050
- uses: actions/checkout@v3
51+
- name: Select Xcode
52+
run: sudo xcode-select -s /Applications/Xcode_16.4.app/Contents/Developer
5153
- name: Build unit test target
5254
run: |
5355
xcodebuild \

GoogleSignInSwift/Sources/GoogleSignInButtonViewModel.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class GoogleSignInButtonViewModel: ObservableObject {
2828

2929
/// A computed property providing the button's size, colors, corner radius,
3030
/// and shadow based on this current view model's `SignInButtonStyle`.
31+
@MainActor
3132
var buttonStyle: SwiftUIButtonStyle {
3233
return SwiftUIButtonStyle(style: style, state: state, scheme: scheme)
3334
}

GoogleSignInSwift/Tests/Unit/GoogleSignInButtonStylingTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import XCTest
1818
@testable import GoogleSignInSwift
1919

20+
@MainActor
2021
@available(iOS 13.0, macOS 10.15, *)
2122
class GoogleSignInButtonStylingTests: XCTestCase {
2223
private typealias ButtonViewModelInfo = (

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.5
1+
// swift-tools-version:6.0
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
// Copyright 2021 Google LLC

Package@swift-5.5.swift

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
// swift-tools-version:5.5
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
// Copyright 2021 Google LLC
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
18+
import PackageDescription
19+
20+
let googleSignInVersion = "9.0.0"
21+
22+
let package = Package(
23+
name: "GoogleSignIn",
24+
defaultLocalization: "en",
25+
platforms: [
26+
.macOS(.v10_15),
27+
.iOS(.v12)
28+
],
29+
products: [
30+
.library(
31+
name: "GoogleSignIn",
32+
targets: [
33+
"GoogleSignIn",
34+
]
35+
),
36+
.library(
37+
name: "GoogleSignInSwift",
38+
targets: [
39+
"GoogleSignInSwift",
40+
]
41+
),
42+
],
43+
dependencies: [
44+
.package(
45+
name: "AppAuth",
46+
url: "https://github.com/openid/AppAuth-iOS.git",
47+
from: "2.0.0"),
48+
.package(
49+
name: "AppCheck",
50+
url: "https://github.com/google/app-check.git",
51+
from: "11.0.0"),
52+
.package(
53+
name: "GTMAppAuth",
54+
url: "https://github.com/google/GTMAppAuth.git",
55+
from: "5.0.0"),
56+
.package(
57+
name: "GTMSessionFetcher",
58+
url: "https://github.com/google/gtm-session-fetcher.git",
59+
from: "3.3.0"),
60+
.package(
61+
name: "OCMock",
62+
url: "https://github.com/firebase/ocmock.git",
63+
.revision("7291762d3551c5c7e31c49cce40a0e391a52e889")),
64+
.package(
65+
name: "GoogleUtilities",
66+
url: "https://github.com/google/GoogleUtilities.git",
67+
from: "8.0.0"),
68+
],
69+
targets: [
70+
.target(
71+
name: "GoogleSignIn",
72+
dependencies: [
73+
.product(name: "AppAuth", package: "AppAuth"),
74+
.product(name: "AppAuthCore", package: "AppAuth"),
75+
.product(name: "AppCheckCore", package: "AppCheck"),
76+
.product(name: "GTMAppAuth", package: "GTMAppAuth"),
77+
.product(name: "GTMSessionFetcherCore", package: "GTMSessionFetcher"),
78+
],
79+
path: "GoogleSignIn/Sources",
80+
resources: [
81+
.process("Resources"),
82+
.process("Strings"),
83+
],
84+
publicHeadersPath: "Public",
85+
cSettings: [
86+
.headerSearchPath("../../"),
87+
.define("GID_SDK_VERSION", to: googleSignInVersion),
88+
],
89+
linkerSettings: [
90+
.linkedFramework("CoreGraphics"),
91+
.linkedFramework("CoreText"),
92+
.linkedFramework("Foundation"),
93+
.linkedFramework("LocalAuthentication"),
94+
.linkedFramework("Security"),
95+
.linkedFramework("AppKit", .when(platforms: [.macOS])),
96+
.linkedFramework("UIKit", .when(platforms: [.iOS])),
97+
]
98+
),
99+
.target(
100+
name: "GoogleSignInSwift",
101+
dependencies: [
102+
"GoogleSignIn",
103+
],
104+
path: "GoogleSignInSwift/Sources",
105+
resources: [
106+
.copy("Resources/PrivacyInfo.xcprivacy")
107+
]
108+
),
109+
.testTarget(
110+
name: "GoogleSignIn-UnitTests",
111+
dependencies: [
112+
"GoogleSignIn",
113+
"OCMock",
114+
.product(name: "AppAuth", package: "AppAuth"),
115+
.product(name: "AppCheckCore", package: "AppCheck"),
116+
.product(name: "GTMAppAuth", package: "GTMAppAuth"),
117+
.product(name: "GTMSessionFetcherCore", package: "GTMSessionFetcher"),
118+
.product(name: "GULMethodSwizzler", package: "GoogleUtilities"),
119+
.product(name: "GULSwizzlerTestHelpers", package: "GoogleUtilities"),
120+
],
121+
path: "GoogleSignIn/Tests/Unit",
122+
cSettings: [
123+
.headerSearchPath("../../../"),
124+
.define("GID_SDK_VERSION", to: googleSignInVersion),
125+
]
126+
),
127+
.testTarget(
128+
name: "GoogleSignInSwift-UnitTests",
129+
dependencies: ["GoogleSignInSwift"],
130+
path: "GoogleSignInSwift/Tests/Unit"
131+
)
132+
]
133+
)

Samples/Swift/DaysUntilBirthday/DaysUntilBirthdayUITests(iOS)/DaysUntilBirthdayUITests_iOS.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ class DaysUntilBirthdayUITests_iOS: XCTestCase {
2020
private let signInStaticText =
2121
"“DaysUntilBirthday (iOS)” Wants to Use “google.com” to Sign In"
2222
private let passwordManagerPrompt =
23-
"Would you like to save this password to use with apps and websites?"
23+
"Save Password?"
2424
private let signInDisclaimerHeaderText =
25-
"Sign in to Days Until Birthday"
25+
"Sign in to DaysUntilBirthday (iOS)"
2626
private let returningUserSignInDisclaimerHeaderText =
27-
"You’re signing back in to Days Until Birthday"
28-
private let additionalAccessHeaderText = "Days Until Birthday wants additional access to your Google Account"
29-
private let appTrustWarningText = "Make sure you trust Days Until Birthday"
27+
"You’re signing back in to DaysUntilBirthday (iOS)"
28+
private let additionalAccessHeaderText = "DaysUntilBirthday (iOS) wants additional access to your Google Account"
29+
private let appTrustWarningText = "Make sure you trust DaysUntilBirthday (iOS)"
3030
private let chooseAnAccountHeaderText = "Choose an account"
3131
private let notNowText = "Not Now"
3232
private let timeout: TimeInterval = 30
@@ -177,6 +177,7 @@ extension DaysUntilBirthdayUITests_iOS {
177177
// Proceed through sign-in disclaimer and/or access request view(s) if needed
178178
handleSignInDisclaimerIfNeeded()
179179
handleAccessRequestIfNeeded()
180+
handleReturningUserSignInDisclaimerIfNeeded()
180181

181182
return true
182183
}
@@ -191,8 +192,9 @@ extension DaysUntilBirthdayUITests_iOS {
191192
return false
192193
}
193194

194-
handleReturningUserSignInDisclaimerIfNeeded()
195+
handleSignInDisclaimerIfNeeded()
195196
handleAccessRequestIfNeeded()
197+
handleReturningUserSignInDisclaimerIfNeeded()
196198

197199
return true
198200
}

Samples/Swift/DaysUntilBirthday/README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ The email and password that we use are defined as
3535
[secrets](https://docs.github.com/en/actions/learn-github-actions/contexts#secrets-context)
3636
on our GitHub repo, and we retrieve these from the workflow environment.
3737

38-
Locally, both the email and password need to be passed to `xcodebuild` as
39-
arguments: `xcodebuild <other args> EMAIL_SECRET=... PASSWORD_SECRET=...`.
40-
Refer to the repo's Secrets for these values.
38+
When run locally, both the email and password need to be passed to `xcodebuild`.
39+
40+
In Xcode, you can add arguments by selecting "Edit Scheme > Run > Environment Variables", and
41+
replace the variables with your test account. Alternatively, edit `Credential.swift` directly.
42+
WARNING: Don't check these into the repo!
43+
44+
From the command line, you can do this as arguments:
45+
`xcodebuild <other args> EMAIL_SECRET=... PASSWORD_SECRET=...`.
46+
47+
For Googlers, refer to CSI internal Workflow documentation for how to access these values, or access
48+
them via the repo's Secrets.

Samples/Swift/DaysUntilBirthday/Shared/Services/GoogleSignInAuthenticator.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ final class GoogleSignInAuthenticator: ObservableObject {
2929

3030
/// Signs in the user based upon the selected account.'
3131
/// - note: Successful calls to this will set the `authViewModel`'s `state` property.
32-
func signIn() {
32+
@MainActor func signIn() {
3333
#if os(iOS)
3434
guard let rootViewController = UIApplication.shared.windows.first?.rootViewController else {
3535
print("There is no root view controller!")
@@ -98,7 +98,7 @@ final class GoogleSignInAuthenticator: ObservableObject {
9898
/// `addScopes(_:presenting:)` request.
9999
/// - note: Successful requests will update the `authViewModel.state` with a new current user that
100100
/// has the granted scope.
101-
func addBirthdayReadScope(completion: @escaping () -> Void) {
101+
@MainActor func addBirthdayReadScope(completion: @escaping () -> Void) {
102102
guard let currentUser = GIDSignIn.sharedInstance.currentUser else {
103103
fatalError("No user signed in!")
104104
}

0 commit comments

Comments
 (0)