From 6e86c15201f46f3ae4d6ce0ed3297119bc3aed77 Mon Sep 17 00:00:00 2001 From: Ian Wagner Date: Thu, 8 Aug 2024 15:11:45 +0900 Subject: [PATCH 1/5] 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) } } From e9df3bb105592122efd06f5659a3685c17a6d6ea Mon Sep 17 00:00:00 2001 From: Ian Wagner Date: Thu, 8 Aug 2024 15:54:39 +0900 Subject: [PATCH 2/5] Upgrade Xcode --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 98040f0..befd864 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,7 +29,7 @@ jobs: ] destination: [ # TODO: Add more destinations - 'platform=iOS Simulator,name=iPhone 15,OS=17.2' + 'platform=iOS Simulator,name=iPhone 15,OS=17.5' ] steps: @@ -38,7 +38,7 @@ jobs: - uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: '15.2' + xcode-version: '15.4' - name: Checkout maplibre-swiftui-dsl-playground uses: actions/checkout@v4 From 7bff6a65e39cb108875480c0ce4591bda806c33e Mon Sep 17 00:00:00 2001 From: Ian Wagner Date: Thu, 8 Aug 2024 15:56:14 +0900 Subject: [PATCH 3/5] Don't double-run on push and PR --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index befd864..e5ecac8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,7 +2,7 @@ name: Test on: push: - branches: [ "*" ] + branches: [ main ] pull_request: branches: [ main ] From 3771d02418b3cdd039655dbe201675168b91f8af Mon Sep 17 00:00:00 2001 From: Ian Wagner Date: Thu, 8 Aug 2024 16:04:22 +0900 Subject: [PATCH 4/5] Cleanup --- Sources/MapLibreSwiftUI/MapViewCoordinator.swift | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Sources/MapLibreSwiftUI/MapViewCoordinator.swift b/Sources/MapLibreSwiftUI/MapViewCoordinator.swift index 967b973..6ce461a 100644 --- a/Sources/MapLibreSwiftUI/MapViewCoordinator.swift +++ b/Sources/MapLibreSwiftUI/MapViewCoordinator.swift @@ -348,18 +348,14 @@ public class MapViewCoordinator: NSObject, MLNMapV /// The MapView's region has changed with a specific reason. 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. MainActor.assumeIsolated { updateViewPort(mapView: mapView, reason: reason) - } - - guard !suppressCameraUpdatePropagation else { - return - } + + guard !suppressCameraUpdatePropagation else { + return + } - // 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 - MainActor.assumeIsolated { updateParentCamera(mapView: mapView, reason: reason) } } From 839f92d8a4ea501deea7dd42fd5dd17adbd6a27f Mon Sep 17 00:00:00 2001 From: Ian Wagner Date: Thu, 8 Aug 2024 16:19:22 +0900 Subject: [PATCH 5/5] swiftformat --- Sources/MapLibreSwiftUI/MapViewCoordinator.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/MapLibreSwiftUI/MapViewCoordinator.swift b/Sources/MapLibreSwiftUI/MapViewCoordinator.swift index 6ce461a..4771697 100644 --- a/Sources/MapLibreSwiftUI/MapViewCoordinator.swift +++ b/Sources/MapLibreSwiftUI/MapViewCoordinator.swift @@ -351,7 +351,7 @@ public class MapViewCoordinator: NSObject, MLNMapV // TODO: We could put this in regionIsChangingWith if we calculate significant change/debounce. MainActor.assumeIsolated { updateViewPort(mapView: mapView, reason: reason) - + guard !suppressCameraUpdatePropagation else { return }