devicekit / DeviceKit

DeviceKit is a value-type replacement of UIDevice.
MIT License
4.39k stars 425 forks source link

Add support for Apple Vision Pro #387

Open edorphy opened 5 months ago

edorphy commented 5 months ago

New device coming soon. Has anyone had a chance at a developer lab with the Apple Vision Pro to know what the hardware id is?

I'm trying to reliably determine if the app running in Designed for iPad mode is on visionOS or not. There is no ProcessInfo .isVision func like there is for running on Mac.

gabors commented 5 months ago

@Zandor300 Please add enough support so we can compile on visionOS for now, actual features can come later.

kudit commented 5 months ago

I'm working on a fork that does support visionOS and macOS. If you're interested in contributing there, try http://github.com/kudit/DeviceKit

Zandor300 commented 5 months ago

I am currently on holiday, next week I will try to take a look. @gabors

Zandor300 commented 5 months ago

@edorphy I am curious, you would like to detect if you are running on visionOS using 'Designed for iPad' mode or natively. What will DeviceKit report as device when the app is running on visionOS? Have you tried this already?

kudit commented 3 months ago

I've created a spinoff project that supports visionOS and macOS and can be developed using Swift Playgrounds in addition to Xcode. It's designed to be easier to maintain with new device idioms and versions. If you have any feedback, please let me know. http://github.com/kudit/Device

gabors commented 3 months ago

@kudit I've created this a while ago that has I use for Mac info, it has lots of Mac data, except the recent M3 crop

https://github.com/voyager-software/MacLookup

edorphy commented 3 months ago

@Zandor300 It would be good first and foremost to add platform support for this, and macOS, in the swift package itself. This at least helps us not have to conditionally link the framework. I understand there is more work because not all of the things like screen dimensions apply. Those would be appropriately marked with @unavailable as necessary. https://github.com/devicekit/DeviceKit/blob/fe41d18eccd92a115cffaa35dfff03018c67e635/Package.swift#L17

As for decoding WHEN on visionOS, there is only one device that reports as "RealityDevice14,1" --> Apple Vision Pro.

When you're running in "Designed for iPad" mode, the device reports itself as an iPad and you can't tell that it is visionOS. There isn't a ProcessInfo property like there is for detecting Apple Silicon :(

kudit commented 3 months ago

@kudit I've created this a while ago that has I use for Mac info, it has lots of Mac data, except the recent M3 crop

https://github.com/voyager-software/MacLookup

@gabors That's awesome! I'll try to write a script to put it in the format for adding to kudit/Device. I should be able to add colors and your other fields as additional parameters in the Mac spec and update my "Form" enum to include various descriptions. Thank you!