Skip to content

Commit eaaa0a6

Browse files
authored
Fix SPM AppCheck build for watchOS (#9226)
1 parent 7d9da3c commit eaaa0a6

File tree

4 files changed

+28
-39
lines changed

4 files changed

+28
-39
lines changed

.github/workflows/app_check.yml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,25 +80,9 @@ jobs:
8080
# Don't run on private repo unless it is a PR.
8181
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
8282
runs-on: macos-11
83-
steps:
84-
- uses: actions/checkout@v2
85-
- uses: mikehardy/buildcache-action@50738c6c77de7f34e66b870e4f8ede333b69d077
86-
with:
87-
cache_key: ${{ matrix.os }}
88-
- name: Initialize xcodebuild
89-
run: scripts/setup_spm_tests.sh
90-
- name: iOS Unit Tests
91-
run: scripts/third_party/travis/retry.sh ./scripts/build.sh AppCheckUnit iOS spm
92-
- name: iOS Swift Unit Tests
93-
run: scripts/third_party/travis/retry.sh ./scripts/build.sh AppCheckUnitSwift iOS spm
94-
95-
spm-cron:
96-
# Don't run on private repo.
97-
if: github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk'
98-
runs-on: macos-11
9983
strategy:
10084
matrix:
101-
target: [tvOS, macOS, catalyst]
85+
target: [iOS, tvOS, macOS, catalyst, watchOS]
10286
steps:
10387
- uses: actions/checkout@v2
10488
- uses: mikehardy/buildcache-action@50738c6c77de7f34e66b870e4f8ede333b69d077

FirebaseAppCheck/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# v8.12.0 -- M111
2+
- [fixed] Build failures with Swift Package Manager for watchOS. (#9191)
3+
14
# v8.9.0 -- M106
25
- [fixed] Improved error handling logic by minimizing amount of requests that are unlikely to succeed. (#8798)
36

FirebaseAppCheck/Tests/Unit/Swift/AppCheckAPITests.swift

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -160,31 +160,33 @@ final class AppCheckAPITests {
160160
// MARK: - DeviceCheckProvider
161161

162162
// `DeviceCheckProvider` initializer
163-
if #available(iOS 11.0, macOS 10.15, macCatalyst 13.0, tvOS 11.0, *) {
164-
if let app = FirebaseApp.app(), let deviceCheckProvider = DeviceCheckProvider(app: app) {
165-
// Get token
166-
deviceCheckProvider.getToken { token, error in
167-
if let _ /* error */ = error {
168-
// ...
169-
} else if let _ /* token */ = token {
170-
// ...
163+
#if !os(watchOS)
164+
if #available(iOS 11.0, macOS 10.15, macCatalyst 13.0, tvOS 11.0, *) {
165+
if let app = FirebaseApp.app(), let deviceCheckProvider = DeviceCheckProvider(app: app) {
166+
// Get token
167+
deviceCheckProvider.getToken { token, error in
168+
if let _ /* error */ = error {
169+
// ...
170+
} else if let _ /* token */ = token {
171+
// ...
172+
}
171173
}
172-
}
173-
// Get token (async/await)
174-
#if compiler(>=5.5) && canImport(_Concurrency)
175-
if #available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) {
176-
// async/await is a Swift 5.5+ feature available on iOS 15+
177-
Task {
178-
do {
179-
_ = try await deviceCheckProvider.getToken()
180-
} catch {
181-
// ...
174+
// Get token (async/await)
175+
#if compiler(>=5.5) && canImport(_Concurrency)
176+
if #available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) {
177+
// async/await is a Swift 5.5+ feature available on iOS 15+
178+
Task {
179+
do {
180+
_ = try await deviceCheckProvider.getToken()
181+
} catch {
182+
// ...
183+
}
182184
}
183185
}
184-
}
185-
#endif // compiler(>=5.5) && canImport(_Concurrency)
186+
#endif // compiler(>=5.5) && canImport(_Concurrency)
187+
}
186188
}
187-
}
189+
#endif // !os(watchOS)
188190
}
189191
}
190192

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ let package = Package(
11381138
.headerSearchPath("../.."),
11391139
],
11401140
linkerSettings: [
1141-
.linkedFramework("DeviceCheck"),
1141+
.linkedFramework("DeviceCheck", .when(platforms: [.iOS, .macOS, .tvOS])),
11421142
]),
11431143
.testTarget(
11441144
name: "AppCheckUnit",

0 commit comments

Comments
 (0)