Skip to content

Commit

Permalink
use canImport(AppKit)
Browse files Browse the repository at this point in the history
  • Loading branch information
honghaoz committed Sep 8, 2024
1 parent aa5dd13 commit 33efb42
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Sources/ChouTiUI/Universal/Layout/Edge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import Foundation

#if os(macOS)
#if canImport(AppKit)
import AppKit
#endif

Expand Down Expand Up @@ -58,7 +58,7 @@ public enum Edge: Sendable {
}
}

#if os(macOS)
#if canImport(AppKit)
/// Converts the edge to `NSRectEdge`.
///
/// Used in `NSPopover`.
Expand Down
2 changes: 1 addition & 1 deletion Sources/ChouTiUI/Universal/Screen/Screen+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public extension Screen {
#if !os(visionOS)
/// The main screen.
static func mainScreen() -> Screen? {
#if os(macOS)
#if canImport(AppKit)
return NSScreen.main
#else
return UIScreen.main
Expand Down
10 changes: 5 additions & 5 deletions Sources/ChouTiUI/Universal/View/View+Layer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public extension View {
///
/// - Warning: On macOS, the view should be layer-backed (set `wantsLayer = true`). Accessing `layer` without setting `wantsLayer = true` will trigger an assertion.
func layer() -> CALayer? {
#if !os(macOS)
#if canImport(AppKit)
ChouTi.assert(layer != nil, "NSView should set `wantsLayer == true`.")
return layer
#else
ChouTi.assert(layer != nil, "NSView should set `wantsLayer == true`.")
return layer
#endif
}
Expand All @@ -56,11 +56,11 @@ public extension View {
///
/// - Warning: On macOS, the view should be layer-backed (set `wantsLayer = true`). Accessing `unsafeLayer` without setting `wantsLayer = true` will crash.
var unsafeLayer: CALayer {
#if !os(macOS)
return layer
#else
#if canImport(AppKit)
ChouTi.assert(layer != nil, "NSView should set `wantsLayer == true`.")
return layer.unsafelyUnwrapped
#else
return layer
#endif
}
}
2 changes: 1 addition & 1 deletion Tests/ChouTiUITests/Universal/Layout/EdgeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import ChouTiUI
import ChouTiTest

#if os(macOS)
#if canImport(AppKit)
import AppKit
#endif

Expand Down

0 comments on commit 33efb42

Please sign in to comment.