PopupView icon indicating copy to clipboard operation
PopupView copied to clipboard

Vision OS Support

Open stephenfung98 opened this issue 1 year ago • 3 comments

Hi Exyte,

I'm getting the following error in Source/Utils.swift

Missing return in getter expected to return 'CGSize'

on static var screenSize: CGSize.

stephenfung98 avatar Jan 14 '24 14:01 stephenfung98

Hey @stephenfung98, unfortunately we do not support visionOS for now, you are most welcome to commit a PR adding this functionality, have a wonderful day!

f3dm76 avatar Jan 14 '24 14:01 f3dm76

Thank you for your response.

I initially believed that the package supported visionOS based on the information available at https://swiftpackageindex.com/exyte/PopupView/builds.

I will explore options to add visionOS compatibility to this package.

stephenfung98 avatar Jan 14 '24 14:01 stephenfung98

I'm not familiar enough with Swift Package Manager to let it give me modifiable files from a github dependency, so I just grabbed source. But I was able to get this working at least enough to do simple toasts and popups on visionOS by merely extending the CGSize extension in Utils.swift:

extension CGSize {

    static var screenSize: CGSize {
#if os(iOS) || os(tvOS)
        return UIScreen.main.bounds.size
#elseif os(watchOS)
        return WKInterfaceDevice.current().screenBounds.size
#elseif os(macOS)
        return NSScreen.main?.frame.size ?? .zero
#else
        // visionOS or something else.  "Full Screen" doesn't really
        // mean much here, so return an arbitrary, reasonable size for a "screen"
        return CGSize(width: 1000, height: 1000)
#endif
    }
}

As the comment implies "Full Screen" is a little undefined on an infinite canvas, but the things you would expect to work do work.

ckempke avatar Feb 11 '24 22:02 ckempke

Hey @stephenfung98, info at Swift Package Index is auto generated for all the platforms, please refer to package.swift file to see supported platforms and versions. Anyway, VisionOS compilation was fixed here https://github.com/exyte/PopupView/issues/187, please check it out.

f3dm76 avatar Jun 17 '24 10:06 f3dm76