From bc73125eb2530c9b1e3598d8536181df4bad7cb9 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 15 Nov 2025 22:10:34 +0000 Subject: [PATCH] Restore CLRegion.contains handling for non-circular regions on macOS/watchOS The previous change removed CLRegion.contains(_:) usage entirely, causing non-circular regions (beacon regions, custom regions) to always return false. While this method is deprecated, it remains functional on macOS and watchOS. This fix: - Restores CLRegion.contains(_:) for non-circular regions on macOS/watchOS - Keeps manual distance calculation for circular regions (avoids deprecation) - Maintains iOS behavior where non-circular regions return false - Documents the platform-specific handling clearly Fixes regression where location specifications with beacon and custom regions stopped working on macOS and watchOS platforms. --- .../Providers/LocationContextProvider.swift | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Sources/SpecificationKit/Providers/LocationContextProvider.swift b/Sources/SpecificationKit/Providers/LocationContextProvider.swift index 3bfcea8..0b283f9 100644 --- a/Sources/SpecificationKit/Providers/LocationContextProvider.swift +++ b/Sources/SpecificationKit/Providers/LocationContextProvider.swift @@ -481,9 +481,20 @@ 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. + // For non-circular regions (e.g., beacon regions, custom regions), + // use the deprecated CLRegion.contains(_:) on platforms where it's still available + #if os(macOS) || os(watchOS) + // CLRegion.contains(_:) is deprecated but still functional on macOS and watchOS + // Suppress the deprecation warning as we need to support non-circular regions + if #available(macOS 11.0, watchOS 7.0, *) { + return region.contains(currentLocation.coordinate) + } + return false + #else + // On iOS and other platforms where CLRegion.contains(_:) is unavailable, + // non-circular regions cannot be evaluated return false + #endif } }