From 3050116a97a3063e8251a9c8958d0faf2b90669f Mon Sep 17 00:00:00 2001 From: Egor Merkushev Date: Tue, 4 Nov 2025 20:23:32 +0300 Subject: [PATCH] Restore direct region containment on macOS and watchOS --- CHANGELOG.md | 7 +++++++ .../Providers/LocationContextProvider.swift | 16 +++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5591508..d44a4ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to SpecificationKit will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed +- Restored non-circular Core Location region evaluation on macOS and watchOS by + calling `CLRegion.contains(_:)` directly without relying on runtime + indirection, preserving behavior from earlier releases. + ## [3.0.0] - 2025-09-18 ### Added - Major Release Features diff --git a/Sources/SpecificationKit/Providers/LocationContextProvider.swift b/Sources/SpecificationKit/Providers/LocationContextProvider.swift index 3bfcea8..804db43 100644 --- a/Sources/SpecificationKit/Providers/LocationContextProvider.swift +++ b/Sources/SpecificationKit/Providers/LocationContextProvider.swift @@ -481,9 +481,19 @@ return distance <= circularRegion.radius } - // CLRegion.contains(_:) is deprecated across Apple platforms, so we only - // evaluate circular regions directly. Non-circular regions fall back to false. - return false + #if os(macOS) || os(watchOS) + let containsRegion: Bool = { + @available(macOS, deprecated: 10.15) + @available(watchOS, deprecated: 6.0) + () -> Bool in + region.contains(currentLocation.coordinate) + }() + return containsRegion + #else + // CLRegion.contains(_:) is unavailable on iOS/tvOS, so non-circular regions + // cannot be evaluated directly. + return false + #endif } }