VisionOS displaylink replacement, UIScreen

Since UIScreen isn't available, is there a drop in replacement for displaylink?

UIScreen.main.displayLink(withTarget: self, selector: #selector(nextFrames))

Error: UIScreen unavailable for xrOS

Related WWDC video: https://developer.apple.com/videos/play/wwdc2023/111215/?time=176

Link to documentation? I also used UIDeviceOrientation, but am hoping there is a snippet for synchronizing Metal frames.

Replies

CADisplayLink has an initializer that doesn't require UIScreen: https://developer.apple.com/documentation/quartzcore/cadisplaylink?language=swift

func createDisplayLink() {
    let displaylink = CADisplayLink(target: self,
                                    selector: #selector(step))
    
    displaylink.add(to: .current,
                    forMode: .defaultRunLoopMode)
}