From 6e86c15201f46f3ae4d6ce0ed3297119bc3aed77 Mon Sep 17 00:00:00 2001 From: Ian Wagner Date: Thu, 8 Aug 2024 15:11:45 +0900 Subject: [PATCH] Adopt Swift 6 concurrency norms --- Sources/MapLibreSwiftUI/MLNMapViewController.swift | 3 ++- Sources/MapLibreSwiftUI/MapViewCoordinator.swift | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Sources/MapLibreSwiftUI/MLNMapViewController.swift b/Sources/MapLibreSwiftUI/MLNMapViewController.swift index 65f3903..c192320 100644 --- a/Sources/MapLibreSwiftUI/MLNMapViewController.swift +++ b/Sources/MapLibreSwiftUI/MLNMapViewController.swift @@ -3,10 +3,11 @@ import UIKit public protocol MapViewHostViewController: UIViewController { associatedtype MapType: MLNMapView - var mapView: MapType { get } + @MainActor var mapView: MapType { get } } public final class MLNMapViewController: UIViewController, MapViewHostViewController { + @MainActor public var mapView: MLNMapView { view as! MLNMapView } diff --git a/Sources/MapLibreSwiftUI/MapViewCoordinator.swift b/Sources/MapLibreSwiftUI/MapViewCoordinator.swift index 52051df..967b973 100644 --- a/Sources/MapLibreSwiftUI/MapViewCoordinator.swift +++ b/Sources/MapLibreSwiftUI/MapViewCoordinator.swift @@ -350,7 +350,7 @@ public class MapViewCoordinator: NSObject, MLNMapV public func mapView(_ mapView: MLNMapView, regionDidChangeWith reason: MLNCameraChangeReason, animated _: Bool) { // FIXME: CI complains about MainActor.assumeIsolated being unavailable before iOS 17, despite building on iOS 17.2... This is an epic hack to fix it for now. I can only assume this is an issue with Xcode pre-15.3 // TODO: We could put this in regionIsChangingWith if we calculate significant change/debounce. - Task { @MainActor in + MainActor.assumeIsolated { updateViewPort(mapView: mapView, reason: reason) } @@ -359,7 +359,7 @@ public class MapViewCoordinator: NSObject, MLNMapV } // FIXME: CI complains about MainActor.assumeIsolated being unavailable before iOS 17, despite building on iOS 17.2... This is an epic hack to fix it for now. I can only assume this is an issue with Xcode pre-15.3 - Task { @MainActor in + MainActor.assumeIsolated { updateParentCamera(mapView: mapView, reason: reason) } }