Skip to content

Commit

Permalink
Fix macOS build failure.
Browse files Browse the repository at this point in the history
The `#available(iOS 16)` wasn't preventing the `anchorPoint` from being set, but that is only available on `UIView`, not `NSView`. Ensuring `UIKit` is available fixes the error, and we fall back to `centerOffset` otherwise.
  • Loading branch information
darronschall committed Oct 2, 2023
1 parent f9dce1b commit c169580
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/Annotations/MKMapAnnotationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ class MKMapAnnotationView<Content: View>: MKAnnotationView {
controller.view.backgroundColor = .clear
#endif

#if canImport(UIKit)
if #available(iOS 16, *) {
anchorPoint = mapAnnotation.anchorPoint.toCGPoint()
} else {
centerOffset = mapAnnotation.anchorPoint.toCenterOffset(in: bounds)
}
#else
centerOffset = mapAnnotation.anchorPoint.toCenterOffset(in: bounds)
#endif
}

// MARK: Overrides
Expand Down

0 comments on commit c169580

Please sign in to comment.