I have a video analysis app and i'm trying to make it compatible with visionOS. It crashes because camera is not allowed; Apple only allows to import videos from Photos.
So I would need to check on launch if the device runs visionOS to show the photos picker rather than the camera view, similarly to what I use right now to check if I'm on macCatalyst or iOS:
#if targetEnvironment(macCatalyst)
print("We are in macOS Catalyst")
#else
print("We are in iOS")
#endif
Thanks in advance.
I've found a workaround with a piece of code here, created to detect iPhone/iPad models:
func modelIdentifier() -> String {
if let simulatorModelIdentifier = ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] { return simulatorModelIdentifier }
var sysinfo = utsname()
uname(&sysinfo) // ignore return value
return String(bytes: Data(bytes: &sysinfo.machine, count: Int(_SYS_NAMELEN)), encoding: .ascii)!.trimmingCharacters(in: .controlCharacters)
}
When calling it in viewDidLoad, it successfully detects the Vision Pro simulator as 'RealityDevice14,1'.