From d3a233773f8d3cfd9f51ba62f3f59d6ff04ffdd5 Mon Sep 17 00:00:00 2001 From: Yang Chao Date: Wed, 10 Jan 2024 01:26:15 +0800 Subject: [PATCH] fix test failure --- Sources/Utility/DisplayLink.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Sources/Utility/DisplayLink.swift b/Sources/Utility/DisplayLink.swift index fa7e79386..801b342c9 100644 --- a/Sources/Utility/DisplayLink.swift +++ b/Sources/Utility/DisplayLink.swift @@ -24,7 +24,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#if !os(macOS) +#if !os(watchOS) +#if canImport(UIKit) import UIKit #else import AppKit @@ -45,7 +46,6 @@ protocol DisplayLinkCompatible: AnyObject { } #if !os(macOS) - extension UIView { func compatibleDisplayLink(target: Any, selector: Selector) -> DisplayLinkCompatible { return CADisplayLink(target: target, selector: selector) @@ -55,21 +55,26 @@ extension UIView { extension CADisplayLink: DisplayLinkCompatible {} #else - extension NSView { func compatibleDisplayLink(target: Any, selector: Selector) -> DisplayLinkCompatible { +#if swift(>=5.9) // macOS 14 SDK is included in Xcode 15, which comes with swift 5.9. Add this check to make old compilers happy. if #available(macOS 14.0, *) { return displayLink(target: target, selector: selector) } else { return DisplayLink(target: target, selector: selector) } +#else + return DisplayLink(target: target, selector: selector) +#endif } } +#if swift(>=5.9) @available(macOS 14.0, *) extension CADisplayLink: DisplayLinkCompatible { var preferredFramesPerSecond: NSInteger { return 0 } } +#endif class DisplayLink: DisplayLinkCompatible { private var link: CVDisplayLink? @@ -155,3 +160,4 @@ class DisplayLink: DisplayLinkCompatible { } } #endif +#endif