From eabfb19dac569b5423340318227f84b6261ac7be Mon Sep 17 00:00:00 2001 From: Fawkes Wei Date: Tue, 28 Oct 2025 09:55:26 +0100 Subject: [PATCH 1/2] Add watchOS support by conditionally compiling MKMapView functions - Added watchOS(.v10) to supported platforms - Wrapped MKMapView-dependent functions with #if !os(watchOS) - Functions wrapped: currentZoom, currentRoundedZoom, coordinateRegion - These functions are only for map display/zoom, not coordinate conversion --- Package.swift | 2 +- grid-ios/tile/TileUtils.swift | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index d9a98a9..fb28e6c 100644 --- a/Package.swift +++ b/Package.swift @@ -4,7 +4,7 @@ import PackageDescription let package = Package( name: "Grid", - platforms: [.macOS(.v11), .iOS(.v13)], + platforms: [.macOS(.v11), .iOS(.v13), .watchOS(.v10)], products: [ .library( name: "Grid", diff --git a/grid-ios/tile/TileUtils.swift b/grid-ios/tile/TileUtils.swift index df207db..69137d5 100644 --- a/grid-ios/tile/TileUtils.swift +++ b/grid-ios/tile/TileUtils.swift @@ -136,6 +136,7 @@ public class TileUtils { return toGridPoint(toCoordinate(point)) } + #if !os(watchOS) /** * Get the current zoom level of the map view * @@ -194,4 +195,5 @@ public class TileUtils { return region } + #endif } From 7ee08f20d9dabfd8077e974c37fa4e91aada6859 Mon Sep 17 00:00:00 2001 From: Fawkes Wei Date: Tue, 28 Oct 2025 09:49:07 +0100 Subject: [PATCH 2/2] Wrap UIScreen.main usage for watchOS compatibility - Added platform conditional for tileLength() function - UIScreen is unavailable on watchOS --- grid-ios/tile/TileUtils.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grid-ios/tile/TileUtils.swift b/grid-ios/tile/TileUtils.swift index 69137d5..ec0af8b 100644 --- a/grid-ios/tile/TileUtils.swift +++ b/grid-ios/tile/TileUtils.swift @@ -32,7 +32,8 @@ public class TileUtils { * High density scale */ public static let SCALE_FACTOR_DEFAULT: Float = 2.0 - + + #if !os(watchOS) /** * Get the tile side (width and height) dimension based upon the screen resolution * @@ -41,6 +42,7 @@ public class TileUtils { public static func tileLength() -> Int { return tileLength(Float(UIScreen.main.nativeScale)) } + #endif /** * Get the tile side (width and height) dimension based upon the scale