From 3834d1ba91b823d91cb9340bba4387d51ebe40d7 Mon Sep 17 00:00:00 2001 From: Jacob Fielding Date: Sun, 16 Mar 2025 10:07:03 -0700 Subject: [PATCH 1/6] feat: swift 6 --- Package.swift | 13 +++++++------ Sources/MapLibreSwiftUI/MapViewCoordinator.swift | 14 +++++++------- .../Examples/CameraPreviewTests.swift | 1 + .../MapView/MapViewGestureTests.swift | 4 ++-- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Package.swift b/Package.swift index 8b9ec7c..a22b190 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.10 +// swift-tools-version: 6.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import CompilerPluginSupport @@ -21,7 +21,8 @@ let package = Package( ), ], dependencies: [ - .package(url: "https://github.com/maplibre/maplibre-gl-native-distribution.git", from: "6.10.0"), + .package( + url: "https://github.com/maplibre/maplibre-gl-native-distribution.git", from: "6.10.0"), .package(url: "https://github.com/stadiamaps/maplibre-swift-macros.git", from: "0.0.5"), // Testing .package(url: "https://github.com/Kolos65/Mockable.git", from: "0.2.0"), @@ -49,16 +50,16 @@ let package = Package( .product(name: "MapLibreSwiftMacros", package: "maplibre-swift-macros"), ], swiftSettings: [ - .enableExperimentalFeature("StrictConcurrency"), + .enableExperimentalFeature("StrictConcurrency") ] ), .target( name: "InternalUtils", dependencies: [ - .product(name: "MapLibre", package: "maplibre-gl-native-distribution"), + .product(name: "MapLibre", package: "maplibre-gl-native-distribution") ], swiftSettings: [ - .enableExperimentalFeature("StrictConcurrency"), + .enableExperimentalFeature("StrictConcurrency") ] ), @@ -75,7 +76,7 @@ let package = Package( .testTarget( name: "MapLibreSwiftDSLTests", dependencies: [ - "MapLibreSwiftDSL", + "MapLibreSwiftDSL" ] ), ] diff --git a/Sources/MapLibreSwiftUI/MapViewCoordinator.swift b/Sources/MapLibreSwiftUI/MapViewCoordinator.swift index 0157bc0..ad9484f 100644 --- a/Sources/MapLibreSwiftUI/MapViewCoordinator.swift +++ b/Sources/MapLibreSwiftUI/MapViewCoordinator.swift @@ -2,7 +2,7 @@ import Foundation import MapLibre import MapLibreSwiftDSL -public class MapViewCoordinator: NSObject, MLNMapViewDelegate { +public class MapViewCoordinator: NSObject, @preconcurrency MLNMapViewDelegate { // This must be weak, the UIViewRepresentable owns the MLNMapView. weak var mapView: MLNMapView? var parent: MapView @@ -267,7 +267,7 @@ public class MapViewCoordinator: NSObject, MLNMapV } } - func addLayers(to mglStyle: MLNStyle) { + @MainActor func addLayers(to mglStyle: MLNStyle) { let firstSymbolLayer = mglStyle.layers.first { layer in layer is MLNSymbolStyleLayer } @@ -318,7 +318,7 @@ public class MapViewCoordinator: NSObject, MLNMapV // MARK: - MLNMapViewDelegate - public func mapView(_: MLNMapView, didFinishLoading mglStyle: MLNStyle) { + @MainActor public func mapView(_: MLNMapView, didFinishLoading mglStyle: MLNStyle) { addLayers(to: mglStyle) onStyleLoaded?(mglStyle) } @@ -373,9 +373,9 @@ 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) { - // TODO: We could put this in regionIsChangingWith if we calculate significant change/debounce. - MainActor.assumeIsolated { + @MainActor public func mapView(_ mapView: MLNMapView, regionDidChangeWith reason: MLNCameraChangeReason, animated _: Bool) { +// // TODO: We could put this in regionIsChangingWith if we calculate significant change/debounce. +// MainActor.assumeIsolated { updateViewProxy(mapView: mapView, reason: reason) guard !suppressCameraUpdatePropagation else { @@ -383,7 +383,7 @@ public class MapViewCoordinator: NSObject, MLNMapV } updateParentCamera(mapView: mapView, reason: reason) - } +// } } // MARK: MapViewProxy diff --git a/Tests/MapLibreSwiftUITests/Examples/CameraPreviewTests.swift b/Tests/MapLibreSwiftUITests/Examples/CameraPreviewTests.swift index 5fff98a..fee80f3 100644 --- a/Tests/MapLibreSwiftUITests/Examples/CameraPreviewTests.swift +++ b/Tests/MapLibreSwiftUITests/Examples/CameraPreviewTests.swift @@ -2,6 +2,7 @@ import SnapshotTesting import XCTest @testable import MapLibreSwiftUI +@MainActor final class CameraPreviewTests: XCTestCase { func testCameraPreview() { assertView { diff --git a/Tests/MapLibreSwiftUITests/MapView/MapViewGestureTests.swift b/Tests/MapLibreSwiftUITests/MapView/MapViewGestureTests.swift index 83a9c79..71ba749 100644 --- a/Tests/MapLibreSwiftUITests/MapView/MapViewGestureTests.swift +++ b/Tests/MapLibreSwiftUITests/MapView/MapViewGestureTests.swift @@ -3,10 +3,10 @@ import Mockable import XCTest @testable import MapLibreSwiftUI +@MainActor final class MapViewGestureTests: XCTestCase { let maplibreMapView = MLNMapView() - - @MainActor + let mapView = MapView(styleURL: URL(string: "https://maplibre.org")!) // MARK: Gesture View Modifiers From a3e7456faf22dbbfe0c491968c838bae2eabc159 Mon Sep 17 00:00:00 2001 From: Jacob Fielding Date: Sun, 16 Mar 2025 10:10:58 -0700 Subject: [PATCH 2/6] feat: swift 6 --- Package.swift | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Package.swift b/Package.swift index a22b190..9cac379 100644 --- a/Package.swift +++ b/Package.swift @@ -39,7 +39,6 @@ let package = Package( ], swiftSettings: [ .define("MOCKING", .when(configuration: .debug)), - .enableExperimentalFeature("StrictConcurrency"), ] ), .target( @@ -48,18 +47,12 @@ let package = Package( .target(name: "InternalUtils"), .product(name: "MapLibre", package: "maplibre-gl-native-distribution"), .product(name: "MapLibreSwiftMacros", package: "maplibre-swift-macros"), - ], - swiftSettings: [ - .enableExperimentalFeature("StrictConcurrency") ] ), .target( name: "InternalUtils", dependencies: [ .product(name: "MapLibre", package: "maplibre-gl-native-distribution") - ], - swiftSettings: [ - .enableExperimentalFeature("StrictConcurrency") ] ), From 1c6ae962646bb259197378d3600411581cc2af29 Mon Sep 17 00:00:00 2001 From: Jacob Fielding Date: Sun, 16 Mar 2025 10:12:48 -0700 Subject: [PATCH 3/6] feat: swift 6 --- Sources/MapLibreSwiftUI/MapViewCoordinator.swift | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Sources/MapLibreSwiftUI/MapViewCoordinator.swift b/Sources/MapLibreSwiftUI/MapViewCoordinator.swift index ad9484f..2a7d2c8 100644 --- a/Sources/MapLibreSwiftUI/MapViewCoordinator.swift +++ b/Sources/MapLibreSwiftUI/MapViewCoordinator.swift @@ -374,16 +374,14 @@ public class MapViewCoordinator: NSObject, @precon /// The MapView's region has changed with a specific reason. @MainActor public func mapView(_ mapView: MLNMapView, regionDidChangeWith reason: MLNCameraChangeReason, animated _: Bool) { -// // TODO: We could put this in regionIsChangingWith if we calculate significant change/debounce. -// MainActor.assumeIsolated { - updateViewProxy(mapView: mapView, reason: reason) + // TODO: We could put this in regionIsChangingWith if we calculate significant change/debounce. + updateViewProxy(mapView: mapView, reason: reason) - guard !suppressCameraUpdatePropagation else { - return - } + guard !suppressCameraUpdatePropagation else { + return + } - updateParentCamera(mapView: mapView, reason: reason) -// } + updateParentCamera(mapView: mapView, reason: reason) } // MARK: MapViewProxy From 8565ac104cddf49a5b211529f062e6c5ced1b6f0 Mon Sep 17 00:00:00 2001 From: Jacob Fielding Date: Sun, 16 Mar 2025 10:14:23 -0700 Subject: [PATCH 4/6] feat: swift 6 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc38807..b10f6d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Upcoming + +- Upgrades project to Swift 6 with swift-tools-version 6.0. + ## Version 0.7.0 - 2025-02-02 ### Added From 7c16a31309b596b2dffc0ca4f47634d5a59aba76 Mon Sep 17 00:00:00 2001 From: Jacob Fielding Date: Sun, 16 Mar 2025 10:14:33 -0700 Subject: [PATCH 5/6] feat: swift 6 --- Package.swift | 7 ++++--- Sources/MapLibreSwiftUI/MapViewCoordinator.swift | 6 +++++- .../MapLibreSwiftUITests/MapView/MapViewGestureTests.swift | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Package.swift b/Package.swift index 9cac379..d1bc562 100644 --- a/Package.swift +++ b/Package.swift @@ -22,7 +22,8 @@ let package = Package( ], dependencies: [ .package( - url: "https://github.com/maplibre/maplibre-gl-native-distribution.git", from: "6.10.0"), + url: "https://github.com/maplibre/maplibre-gl-native-distribution.git", from: "6.10.0" + ), .package(url: "https://github.com/stadiamaps/maplibre-swift-macros.git", from: "0.0.5"), // Testing .package(url: "https://github.com/Kolos65/Mockable.git", from: "0.2.0"), @@ -52,7 +53,7 @@ let package = Package( .target( name: "InternalUtils", dependencies: [ - .product(name: "MapLibre", package: "maplibre-gl-native-distribution") + .product(name: "MapLibre", package: "maplibre-gl-native-distribution"), ] ), @@ -69,7 +70,7 @@ let package = Package( .testTarget( name: "MapLibreSwiftDSLTests", dependencies: [ - "MapLibreSwiftDSL" + "MapLibreSwiftDSL", ] ), ] diff --git a/Sources/MapLibreSwiftUI/MapViewCoordinator.swift b/Sources/MapLibreSwiftUI/MapViewCoordinator.swift index 2a7d2c8..603e4e7 100644 --- a/Sources/MapLibreSwiftUI/MapViewCoordinator.swift +++ b/Sources/MapLibreSwiftUI/MapViewCoordinator.swift @@ -373,7 +373,11 @@ public class MapViewCoordinator: NSObject, @precon } /// The MapView's region has changed with a specific reason. - @MainActor public func mapView(_ mapView: MLNMapView, regionDidChangeWith reason: MLNCameraChangeReason, animated _: Bool) { + @MainActor public func mapView( + _ mapView: MLNMapView, + regionDidChangeWith reason: MLNCameraChangeReason, + animated _: Bool + ) { // TODO: We could put this in regionIsChangingWith if we calculate significant change/debounce. updateViewProxy(mapView: mapView, reason: reason) diff --git a/Tests/MapLibreSwiftUITests/MapView/MapViewGestureTests.swift b/Tests/MapLibreSwiftUITests/MapView/MapViewGestureTests.swift index 71ba749..219a7f5 100644 --- a/Tests/MapLibreSwiftUITests/MapView/MapViewGestureTests.swift +++ b/Tests/MapLibreSwiftUITests/MapView/MapViewGestureTests.swift @@ -6,7 +6,7 @@ import XCTest @MainActor final class MapViewGestureTests: XCTestCase { let maplibreMapView = MLNMapView() - + let mapView = MapView(styleURL: URL(string: "https://maplibre.org")!) // MARK: Gesture View Modifiers From 5483882d2c056ca898d32072a614ceee9390a6e7 Mon Sep 17 00:00:00 2001 From: Jacob Fielding Date: Sun, 16 Mar 2025 16:38:13 -0700 Subject: [PATCH 6/6] feat: swift 6 --- Package.resolved | 27 ++++++++++++++++++--------- Package.swift | 8 ++++---- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Package.resolved b/Package.resolved index b4b5457..009d4e4 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,13 +1,13 @@ { - "originHash" : "38dcbeee72b24bdfa4a2996241d74854484c6c169c780ccbb848c5b91e1f16ce", + "originHash" : "ba3eb8620cdf7e03ce1ee48a09f542740461a2d34a7b185836833a6dd904e309", "pins" : [ { "identity" : "maplibre-gl-native-distribution", "kind" : "remoteSourceControl", "location" : "https://github.com/maplibre/maplibre-gl-native-distribution.git", "state" : { - "revision" : "3615e3cc81b09b78b58b183660815b0f36107b3b", - "version" : "6.10.0" + "revision" : "f609802247705d95e852e4e277e597aa88230e2b", + "version" : "6.12.1" } }, { @@ -15,8 +15,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/stadiamaps/maplibre-swift-macros.git", "state" : { - "revision" : "9e27e62dff7fd727aebd0a7c8aa74e7635a5583e", - "version" : "0.0.5" + "revision" : "92a651a64bdedfea9b55ca365e0101a99a56cf85", + "version" : "0.0.6" } }, { @@ -24,8 +24,17 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/Kolos65/Mockable.git", "state" : { - "revision" : "e1b311b01c11415099341eee49769185e965ac4c", - "version" : "0.2.0" + "revision" : "203336d0ccb7ff03a8a03db54a4fa18fc2b0c771", + "version" : "0.3.0" + } + }, + { + "identity" : "swift-custom-dump", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pointfreeco/swift-custom-dump", + "state" : { + "revision" : "82645ec760917961cfa08c9c0c7104a57a0fa4b1", + "version" : "1.3.3" } }, { @@ -33,8 +42,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-snapshot-testing", "state" : { - "revision" : "2e6a85b73fc14e27d7542165ae73b1a10516ca9a", - "version" : "1.17.7" + "revision" : "b2d4cb30735f4fbc3a01963a9c658336dd21e9ba", + "version" : "1.18.1" } }, { diff --git a/Package.swift b/Package.swift index d1bc562..efe9d67 100644 --- a/Package.swift +++ b/Package.swift @@ -22,12 +22,12 @@ let package = Package( ], dependencies: [ .package( - url: "https://github.com/maplibre/maplibre-gl-native-distribution.git", from: "6.10.0" + url: "https://github.com/maplibre/maplibre-gl-native-distribution.git", from: "6.12.1" ), - .package(url: "https://github.com/stadiamaps/maplibre-swift-macros.git", from: "0.0.5"), + .package(url: "https://github.com/stadiamaps/maplibre-swift-macros.git", from: "0.0.6"), // Testing - .package(url: "https://github.com/Kolos65/Mockable.git", from: "0.2.0"), - .package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.17.7"), + .package(url: "https://github.com/Kolos65/Mockable.git", from: "0.3.0"), + .package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.18.1"), ], targets: [ .target(