Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[App Check] Fix App Attest and DeviceCheck API availability #11662

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,49 +21,20 @@

#pragma mark - DeviceCheck

// DeviceCheck availability was extended to watchOS in Xcode 14.
#if defined(__WATCHOS_9_0) && __WATCH_OS_VERSION_MAX_ALLOWED >= __WATCHOS_9_0

// Targets where DeviceCheck framework is available to be used in preprocessor conditions.
#define FIR_DEVICE_CHECK_SUPPORTED_TARGETS \
TARGET_OS_IOS || TARGET_OS_OSX || TARGET_OS_TV || TARGET_OS_WATCH

// `DeviceCheckProvider` availability.
#define FIR_DEVICE_CHECK_PROVIDER_AVAILABILITY \
API_AVAILABLE(ios(11.0), macos(10.15), tvos(11.0), watchos(9.0))

// TODO(ncooke3): Remove `#else` clause when Xcode 14 is the minimum supported Xcode.
#else // defined(__WATCHOS_9_0) && __WATCH_OS_VERSION_MAX_ALLOWED >= __WATCHOS_9_0

// Targets where DeviceCheck framework is available to be used in preprocessor conditions.
#define FIR_DEVICE_CHECK_SUPPORTED_TARGETS TARGET_OS_IOS || TARGET_OS_OSX || TARGET_OS_TV

// `DeviceCheckProvider` availability.
#define FIR_DEVICE_CHECK_PROVIDER_AVAILABILITY \
API_AVAILABLE(ios(11.0), macos(10.15), tvos(11.0)) API_UNAVAILABLE(watchos)

#endif // defined(__WATCHOS_9_0) && __WATCH_OS_VERSION_MAX_ALLOWED >= __WATCHOS_9_0
API_AVAILABLE(ios(11.0), macos(10.15), macCatalyst(13.0), tvos(11.0), watchos(9.0))

#pragma mark - App Attest

#if defined(__WATCHOS_9_0) && __WATCH_OS_VERSION_MAX_ALLOWED >= __WATCHOS_9_0

// Targets where `DCAppAttestService` is available to be used in preprocessor conditions.
#define FIR_APP_ATTEST_SUPPORTED_TARGETS \
TARGET_OS_IOS || TARGET_OS_OSX || TARGET_OS_TV || TARGET_OS_WATCH

// `AppAttestProvider` availability annotations
#define FIR_APP_ATTEST_PROVIDER_AVAILABILITY \
API_AVAILABLE(macos(11.0), ios(14.0), tvos(15.0), watchos(9.0))

// TODO(ncooke3): Remove `#else` clause when Xcode 14 is the minimum supported Xcode.
#else // defined(__WATCHOS_9_0) && __WATCH_OS_VERSION_MAX_ALLOWED >= __WATCHOS_9_0

// Targets where `DCAppAttestService` is available to be used in preprocessor conditions.
#define FIR_APP_ATTEST_SUPPORTED_TARGETS TARGET_OS_IOS || TARGET_OS_OSX || TARGET_OS_TV

// `AppAttestProvider` availability annotations
#define FIR_APP_ATTEST_PROVIDER_AVAILABILITY \
API_AVAILABLE(macos(11.0), ios(14.0), tvos(15.0)) API_UNAVAILABLE(watchos)

#endif // defined(__WATCHOS_9_0) && __WATCH_OS_VERSION_MAX_ALLOWED >= __WATCHOS_9_0
API_AVAILABLE(ios(14.0), macos(11.3), macCatalyst(14.5), tvos(15.0), watchos(9.0))
12 changes: 5 additions & 7 deletions FirebaseAppCheck/Tests/Unit/Swift/AppCheckAPITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ final class AppCheckAPITests {
func usage() {
// MARK: - AppAttestProvider

#if TARGET_OS_IOS
if #available(iOS 14.0, *) {
if let app = FirebaseApp.app(), let provider = AppAttestProvider(app: app) {
provider.getToken { token, error in
// ...
}
if #available(iOS 14.0, macOS 11.3, macCatalyst 14.5, tvOS 15.0, watchOS 9.0, *) {
if let app = FirebaseApp.app(), let provider = AppAttestProvider(app: app) {
provider.getToken { token, error in
// ...
}
}
#endif // TARGET_OS_IOS
}

// MARK: - AppCheck

Expand Down
Loading