Identify when iOS app runs on VisionOS
Description
It's useful for users to know if their iOS app runs on VisionOS. As of April 4th, 2024, there is no official API for this yet; see Apple forum and Stackoverflow. Once Apple adds an official API similar to NSProcessInfo.iOSAppOnMac we can send this information on the device context.
This is related to https://github.com/getsentry/sentry-cocoa/issues/3825.
related: https://medium.com/@timonus/low-hanging-fruit-for-ios-apps-running-on-visionos-08a85db0fb31
possible workaround: https://github.com/timonus/TJMixpanelLogger/blob/0952cf0ccc54c23d730e45069ec2b56c24ae8e31/TJMixpanelLogger.m#L142-L145
From internal communication by @itaybre:
extension ProcessInfo { public var isiOSAppOnVisionOS: Bool { // `UIWindowSceneGeometryPreferencesVision` is only available // https://developer.apple.com/documentation/uikit/uiwindowscene/geometrypreferences/vision?language=objc return NSClassFromString("UIWindowSceneGeometryPreferencesVision") != nil } }Tested both on device and simulator.