Skip to content

Commit 4b9cbf6

Browse files
authored
[App Check] Fix App Attest and DeviceCheck API availability (#11662)
- Updated the FIR_DEVICE_CHECK_PROVIDER_AVAILABILITY and FIR_APP_ATTEST_PROVIDER_AVAILABILITY API availability macros to reflect the set of supported platforms for DeviceCheck (iOS 11+, macOS 10.15+, macCatalyst 13+, tvOS 11+, watchOS 9+) and App Attest (iOS 14+, macOS 11.3+, macCatalyst 14.5+, tvOS 15+, watchOS 9+). - Removed the extraneous check for the watchOS 9 SDK now that Xcode 14 is the minimum supported by Firebase. Removed the #if TARGET_OS_IOS compiler directive in AppCheckAPITests.swift since TARGET_OS_IOS is only available in Objective-C and was always false.
1 parent 7ad4967 commit 4b9cbf6

File tree

2 files changed

+7
-38
lines changed

2 files changed

+7
-38
lines changed

FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRAppCheckAvailability.h

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,49 +21,20 @@
2121

2222
#pragma mark - DeviceCheck
2323

24-
// DeviceCheck availability was extended to watchOS in Xcode 14.
25-
#if defined(__WATCHOS_9_0) && __WATCH_OS_VERSION_MAX_ALLOWED >= __WATCHOS_9_0
26-
2724
// Targets where DeviceCheck framework is available to be used in preprocessor conditions.
2825
#define FIR_DEVICE_CHECK_SUPPORTED_TARGETS \
2926
TARGET_OS_IOS || TARGET_OS_OSX || TARGET_OS_TV || TARGET_OS_WATCH
3027

3128
// `DeviceCheckProvider` availability.
3229
#define FIR_DEVICE_CHECK_PROVIDER_AVAILABILITY \
33-
API_AVAILABLE(ios(11.0), macos(10.15), tvos(11.0), watchos(9.0))
34-
35-
// TODO(ncooke3): Remove `#else` clause when Xcode 14 is the minimum supported Xcode.
36-
#else // defined(__WATCHOS_9_0) && __WATCH_OS_VERSION_MAX_ALLOWED >= __WATCHOS_9_0
37-
38-
// Targets where DeviceCheck framework is available to be used in preprocessor conditions.
39-
#define FIR_DEVICE_CHECK_SUPPORTED_TARGETS TARGET_OS_IOS || TARGET_OS_OSX || TARGET_OS_TV
40-
41-
// `DeviceCheckProvider` availability.
42-
#define FIR_DEVICE_CHECK_PROVIDER_AVAILABILITY \
43-
API_AVAILABLE(ios(11.0), macos(10.15), tvos(11.0)) API_UNAVAILABLE(watchos)
44-
45-
#endif // defined(__WATCHOS_9_0) && __WATCH_OS_VERSION_MAX_ALLOWED >= __WATCHOS_9_0
30+
API_AVAILABLE(ios(11.0), macos(10.15), macCatalyst(13.0), tvos(11.0), watchos(9.0))
4631

4732
#pragma mark - App Attest
4833

49-
#if defined(__WATCHOS_9_0) && __WATCH_OS_VERSION_MAX_ALLOWED >= __WATCHOS_9_0
50-
5134
// Targets where `DCAppAttestService` is available to be used in preprocessor conditions.
5235
#define FIR_APP_ATTEST_SUPPORTED_TARGETS \
5336
TARGET_OS_IOS || TARGET_OS_OSX || TARGET_OS_TV || TARGET_OS_WATCH
5437

5538
// `AppAttestProvider` availability annotations
5639
#define FIR_APP_ATTEST_PROVIDER_AVAILABILITY \
57-
API_AVAILABLE(macos(11.0), ios(14.0), tvos(15.0), watchos(9.0))
58-
59-
// TODO(ncooke3): Remove `#else` clause when Xcode 14 is the minimum supported Xcode.
60-
#else // defined(__WATCHOS_9_0) && __WATCH_OS_VERSION_MAX_ALLOWED >= __WATCHOS_9_0
61-
62-
// Targets where `DCAppAttestService` is available to be used in preprocessor conditions.
63-
#define FIR_APP_ATTEST_SUPPORTED_TARGETS TARGET_OS_IOS || TARGET_OS_OSX || TARGET_OS_TV
64-
65-
// `AppAttestProvider` availability annotations
66-
#define FIR_APP_ATTEST_PROVIDER_AVAILABILITY \
67-
API_AVAILABLE(macos(11.0), ios(14.0), tvos(15.0)) API_UNAVAILABLE(watchos)
68-
69-
#endif // defined(__WATCHOS_9_0) && __WATCH_OS_VERSION_MAX_ALLOWED >= __WATCHOS_9_0
40+
API_AVAILABLE(ios(14.0), macos(11.3), macCatalyst(14.5), tvos(15.0), watchos(9.0))

FirebaseAppCheck/Tests/Unit/Swift/AppCheckAPITests.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,13 @@ final class AppCheckAPITests {
2525
func usage() {
2626
// MARK: - AppAttestProvider
2727

28-
#if TARGET_OS_IOS
29-
if #available(iOS 14.0, *) {
30-
if let app = FirebaseApp.app(), let provider = AppAttestProvider(app: app) {
31-
provider.getToken { token, error in
32-
// ...
33-
}
28+
if #available(iOS 14.0, macOS 11.3, macCatalyst 14.5, tvOS 15.0, watchOS 9.0, *) {
29+
if let app = FirebaseApp.app(), let provider = AppAttestProvider(app: app) {
30+
provider.getToken { token, error in
31+
// ...
3432
}
3533
}
36-
#endif // TARGET_OS_IOS
34+
}
3735

3836
// MARK: - AppCheck
3937

0 commit comments

Comments
 (0)