diff --git a/Bugsnag/Breadcrumbs/BSGNotificationBreadcrumbs.m b/Bugsnag/Breadcrumbs/BSGNotificationBreadcrumbs.m index 962af8772..8ff03b81b 100644 --- a/Bugsnag/Breadcrumbs/BSGNotificationBreadcrumbs.m +++ b/Bugsnag/Breadcrumbs/BSGNotificationBreadcrumbs.m @@ -318,7 +318,7 @@ - (BOOL)tryAddSceneNotification:(NSNotification *)notification { #endif - (BOOL)tryAddWindowNotification:(NSNotification *)notification { -#if TARGET_OS_IOS || TARGET_OS_TV +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION if ([notification.name hasPrefix:@"UIWindow"] && [notification.object isKindOfClass:UIWINDOW]) { UIWindow *window = notification.object; NSMutableDictionary *metadata = [NSMutableDictionary dictionary]; diff --git a/Bugsnag/Helpers/BSGDefines.h b/Bugsnag/Helpers/BSGDefines.h index 25ac28bf2..729d21bb3 100644 --- a/Bugsnag/Helpers/BSGDefines.h +++ b/Bugsnag/Helpers/BSGDefines.h @@ -10,18 +10,23 @@ #include +#ifndef TARGET_OS_VISION + // For older Xcode that doesn't have VisionOS support... + #define TARGET_OS_VISION 0 +#endif + // Capabilities dependent upon system defines and files -#define BSG_HAVE_BATTERY ( TARGET_OS_IOS || TARGET_OS_WATCH) +#define BSG_HAVE_BATTERY ( TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_VISION) #define BSG_HAVE_MACH_EXCEPTIONS (TARGET_OS_OSX || TARGET_OS_IOS ) -#define BSG_HAVE_MACH_THREADS (TARGET_OS_OSX || TARGET_OS_IOS || TARGET_OS_TV ) +#define BSG_HAVE_MACH_THREADS (TARGET_OS_OSX || TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION) #define BSG_HAVE_OOM_DETECTION ( TARGET_OS_IOS || TARGET_OS_TV ) && !TARGET_OS_SIMULATOR && !TARGET_OS_MACCATALYST -#define BSG_HAVE_REACHABILITY (TARGET_OS_OSX || TARGET_OS_IOS || TARGET_OS_TV ) +#define BSG_HAVE_REACHABILITY (TARGET_OS_OSX || TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION) #define BSG_HAVE_REACHABILITY_WWAN ( TARGET_OS_IOS || TARGET_OS_TV ) -#define BSG_HAVE_SIGNAL (TARGET_OS_OSX || TARGET_OS_IOS || TARGET_OS_TV ) +#define BSG_HAVE_SIGNAL (TARGET_OS_OSX || TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION) #define BSG_HAVE_SIGALTSTACK (TARGET_OS_OSX || TARGET_OS_IOS ) #define BSG_HAVE_SYSCALL (TARGET_OS_IOS || TARGET_OS_TV ) #define BSG_HAVE_UIDEVICE __has_include() -#define BSG_HAVE_WINDOW (TARGET_OS_OSX || TARGET_OS_IOS || TARGET_OS_TV ) +#define BSG_HAVE_WINDOW (TARGET_OS_OSX || TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION) // Capabilities dependent upon previously defined capabilities #define BSG_HAVE_APP_HANG_DETECTION (BSG_HAVE_MACH_THREADS) diff --git a/Bugsnag/Helpers/BSGHardware.h b/Bugsnag/Helpers/BSGHardware.h index ce3c5b95a..6424e6b84 100644 --- a/Bugsnag/Helpers/BSGHardware.h +++ b/Bugsnag/Helpers/BSGHardware.h @@ -17,7 +17,7 @@ #pragma mark Device -#if TARGET_OS_IOS +#if TARGET_OS_IOS || TARGET_OS_VISION static inline UIDevice *BSGGetDevice(void) { return [UIDEVICE currentDevice]; } @@ -32,7 +32,7 @@ static inline WKInterfaceDevice *BSGGetDevice(void) { #if BSG_HAVE_BATTERY static inline BOOL BSGIsBatteryStateKnown(long battery_state) { -#if TARGET_OS_IOS +#if TARGET_OS_IOS || TARGET_OS_VISION const long state_unknown = UIDeviceBatteryStateUnknown; #elif TARGET_OS_WATCH const long state_unknown = WKInterfaceDeviceBatteryStateUnknown; @@ -41,7 +41,7 @@ static inline BOOL BSGIsBatteryStateKnown(long battery_state) { } static inline BOOL BSGIsBatteryCharging(long battery_state) { -#if TARGET_OS_IOS +#if TARGET_OS_IOS || TARGET_OS_VISION const long state_charging = UIDeviceBatteryStateCharging; #elif TARGET_OS_WATCH const long state_charging = WKInterfaceDeviceBatteryStateCharging; diff --git a/Bugsnag/Helpers/BSGRunContext.m b/Bugsnag/Helpers/BSGRunContext.m index 974958b19..58015b685 100644 --- a/Bugsnag/Helpers/BSGRunContext.m +++ b/Bugsnag/Helpers/BSGRunContext.m @@ -40,7 +40,7 @@ static uint64_t GetBootTime(void); static bool GetIsActive(void); static bool GetIsForeground(void); -#if TARGET_OS_IOS || TARGET_OS_TV +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION static UIApplication * GetUIApplication(void); #endif static void InstallTimer(void); @@ -112,7 +112,7 @@ static bool GetIsActive(void) { return GetIsForeground(); #endif -#if TARGET_OS_IOS || TARGET_OS_TV +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION UIApplication *app = GetUIApplication(); return app && app.applicationState == UIApplicationStateActive; #endif @@ -128,6 +128,10 @@ static bool GetIsActive(void) { return true; } #endif + +#if TARGET_OS_VISION + return true; +#endif } static bool GetIsForeground(void) { @@ -160,7 +164,7 @@ static bool GetIsForeground(void) { } #endif -#if TARGET_OS_IOS || TARGET_OS_TV +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION UIApplication *application = GetUIApplication(); // There will be no UIApplication if UIApplicationMain() has not yet been @@ -193,9 +197,13 @@ static bool GetIsForeground(void) { return true; } #endif + +#if TARGET_OS_VISION + return true; +#endif } -#if TARGET_OS_IOS || TARGET_OS_TV +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION static UIApplication * GetUIApplication(void) { // +sharedApplication is unavailable to app extensions diff --git a/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.m b/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.m index b4cb8f570..2d9ba25ab 100644 --- a/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.m +++ b/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.m @@ -289,6 +289,8 @@ + (NSDictionary *)buildSystemInfoStatic { sysInfo[@BSG_KSSystemField_SystemName] = @"tvOS"; #elif TARGET_OS_WATCH sysInfo[@BSG_KSSystemField_SystemName] = @"watchOS"; +#elif TARGET_OS_VISION + sysInfo[@BSG_KSSystemField_SystemName] = @"visionOS"; #endif // TARGET_OS_IOS NSDictionary *env = NSProcessInfo.processInfo.environment; @@ -319,6 +321,8 @@ + (NSDictionary *)buildSystemInfoStatic { NSString *systemName = @"tvOS"; #elif TARGET_OS_WATCH NSString *systemName = @"watchOS"; +#elif TARGET_OS_VISION + NSString *systemName = @"visionOS"; #endif sysInfo[@BSG_KSSystemField_SystemName] = systemName;