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

[Plat-12124] Basic visionOS support #1660

Merged
merged 3 commits into from
Jun 13, 2024
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
2 changes: 1 addition & 1 deletion Bugsnag/Breadcrumbs/BSGNotificationBreadcrumbs.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
15 changes: 10 additions & 5 deletions Bugsnag/Helpers/BSGDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,23 @@

#include <TargetConditionals.h>

#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(<UIKit/UIDevice.h>)
#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)
Expand Down
6 changes: 3 additions & 3 deletions Bugsnag/Helpers/BSGHardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand All @@ -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;
Expand All @@ -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;
Expand Down
16 changes: 12 additions & 4 deletions Bugsnag/Helpers/BSGRunContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -128,6 +128,10 @@ static bool GetIsActive(void) {
return true;
}
#endif

#if TARGET_OS_VISION
return true;
#endif
}

static bool GetIsForeground(void) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Loading