Skip to content

Commit

Permalink
Fix Firestore visionOS build on Xcode 15.1 (#12029)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulb777 authored Oct 31, 2023
1 parent b850d1a commit 822f547
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
3 changes: 3 additions & 0 deletions Firestore/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 11 additions & 6 deletions Firestore/core/src/remote/connectivity_monitor_apple.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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 <UIKit/UIKit.h>
#endif

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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;
Expand Down Expand Up @@ -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<NSObject> observer_ = nil;
#endif
};
Expand Down
5 changes: 3 additions & 2 deletions Firestore/core/src/util/filesystem_apple.mm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
}

StatusOr<Path> 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<NSString*>* directories = NSSearchPathForDirectoriesInDomains(
NSApplicationSupportDirectory, NSUserDomainMask, YES);
return Path::FromNSString(directories[0]).AppendUtf8(app_name);
Expand All @@ -60,7 +61,7 @@
}

StatusOr<Path> Filesystem::LegacyDocumentsDir(absl::string_view app_name) {
#if TARGET_OS_IOS
#if TARGET_OS_IOS || (defined(TARGET_OS_VISION) && TARGET_OS_VISION)
NSArray<NSString*>* directories = NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory, NSUserDomainMask, YES);
return Path::FromNSString(directories[0]).AppendUtf8(app_name);
Expand Down

0 comments on commit 822f547

Please sign in to comment.