From 822f5478dd36f986bb1aab8f7ffecddd8d1d8ced Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Tue, 31 Oct 2023 13:30:53 -0700 Subject: [PATCH] Fix Firestore visionOS build on Xcode 15.1 (#12029) --- Firestore/CHANGELOG.md | 3 +++ .../src/remote/connectivity_monitor_apple.mm | 17 +++++++++++------ Firestore/core/src/util/filesystem_apple.mm | 5 +++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Firestore/CHANGELOG.md b/Firestore/CHANGELOG.md index 44894994b94..8834928cda4 100644 --- a/Firestore/CHANGELOG.md +++ b/Firestore/CHANGELOG.md @@ -1,3 +1,6 @@ +# Unreleased +- [fixed] Fix Firestore build for visionOS on Xcode 15.1. (#12023) + # 10.17.0 - [feature] Add support for sum and average aggregate queries. - [feature] The `FirebaseFirestore` module now contains Firebase Firestore's diff --git a/Firestore/core/src/remote/connectivity_monitor_apple.mm b/Firestore/core/src/remote/connectivity_monitor_apple.mm index 33d6b7e95b7..3fccfc6ef16 100644 --- a/Firestore/core/src/remote/connectivity_monitor_apple.mm +++ b/Firestore/core/src/remote/connectivity_monitor_apple.mm @@ -18,7 +18,8 @@ #if defined(__APPLE__) -#if TARGET_OS_IOS || TARGET_OS_TV +#if TARGET_OS_IOS || TARGET_OS_TV || \ + (defined(TARGET_OS_VISION) && TARGET_OS_VISION) #import #endif @@ -49,7 +50,7 @@ NetworkStatus ToNetworkStatus(SCNetworkReachabilityFlags flags) { return NetworkStatus::Unavailable; } -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || (defined(TARGET_OS_VISION) && TARGET_OS_VISION) if (flags & kSCNetworkReachabilityFlagsIsWWAN) { return NetworkStatus::AvailableViaCellular; } @@ -112,7 +113,8 @@ explicit ConnectivityMonitorApple( return; } -#if TARGET_OS_IOS || TARGET_OS_TV +#if TARGET_OS_IOS || TARGET_OS_TV || \ + (defined(TARGET_OS_VISION) && TARGET_OS_VISION) this->observer_ = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillEnterForegroundNotification object:nil @@ -124,7 +126,8 @@ explicit ConnectivityMonitorApple( } ~ConnectivityMonitorApple() { -#if TARGET_OS_IOS || TARGET_OS_TV +#if TARGET_OS_IOS || TARGET_OS_TV || \ + (defined(TARGET_OS_VISION) && TARGET_OS_VISION) [[NSNotificationCenter defaultCenter] removeObserver:this->observer_]; #endif @@ -139,7 +142,8 @@ explicit ConnectivityMonitorApple( } } -#if TARGET_OS_IOS || TARGET_OS_TV +#if TARGET_OS_IOS || TARGET_OS_TV || \ + (defined(TARGET_OS_VISION) && TARGET_OS_VISION) void OnEnteredForeground() { SCNetworkReachabilityFlags flags{}; if (!SCNetworkReachabilityGetFlags(reachability_, &flags)) return; @@ -167,7 +171,8 @@ void OnReachabilityChanged(SCNetworkReachabilityFlags flags) { private: SCNetworkReachabilityRef reachability_ = nil; -#if TARGET_OS_IOS || TARGET_OS_TV +#if TARGET_OS_IOS || TARGET_OS_TV || \ + (defined(TARGET_OS_VISION) && TARGET_OS_VISION) id observer_ = nil; #endif }; diff --git a/Firestore/core/src/util/filesystem_apple.mm b/Firestore/core/src/util/filesystem_apple.mm index 5a6fdea9c5f..85e4db356f0 100644 --- a/Firestore/core/src/util/filesystem_apple.mm +++ b/Firestore/core/src/util/filesystem_apple.mm @@ -44,7 +44,8 @@ } StatusOr Filesystem::AppDataDir(absl::string_view app_name) { -#if TARGET_OS_IOS || TARGET_OS_OSX +#if TARGET_OS_IOS || TARGET_OS_OSX || \ + (defined(TARGET_OS_VISION) && TARGET_OS_VISION) NSArray* directories = NSSearchPathForDirectoriesInDomains( NSApplicationSupportDirectory, NSUserDomainMask, YES); return Path::FromNSString(directories[0]).AppendUtf8(app_name); @@ -60,7 +61,7 @@ } StatusOr Filesystem::LegacyDocumentsDir(absl::string_view app_name) { -#if TARGET_OS_IOS +#if TARGET_OS_IOS || (defined(TARGET_OS_VISION) && TARGET_OS_VISION) NSArray* directories = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES); return Path::FromNSString(directories[0]).AppendUtf8(app_name);