Skip to content

Upgrades to Swift 6 #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 18 additions & 9 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,40 +1,49 @@
{
"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"
}
},
{
"identity" : "maplibre-swift-macros",
"kind" : "remoteSourceControl",
"location" : "https://github.com/stadiamaps/maplibre-swift-macros.git",
"state" : {
"revision" : "9e27e62dff7fd727aebd0a7c8aa74e7635a5583e",
"version" : "0.0.5"
"revision" : "92a651a64bdedfea9b55ca365e0101a99a56cf85",
"version" : "0.0.6"
}
},
{
"identity" : "mockable",
"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"
}
},
{
"identity" : "swift-snapshot-testing",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
"state" : {
"revision" : "2e6a85b73fc14e27d7542165ae73b1a10516ca9a",
"version" : "1.17.7"
"revision" : "b2d4cb30735f4fbc3a01963a9c658336dd21e9ba",
"version" : "1.18.1"
}
},
{
Expand Down
19 changes: 7 additions & 12 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -21,11 +21,13 @@ let package = Package(
),
],
dependencies: [
.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"),
.package(
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.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(
Expand All @@ -38,7 +40,6 @@ let package = Package(
],
swiftSettings: [
.define("MOCKING", .when(configuration: .debug)),
.enableExperimentalFeature("StrictConcurrency"),
]
),
.target(
Expand All @@ -47,18 +48,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"),
]
),

Expand Down
24 changes: 13 additions & 11 deletions Sources/MapLibreSwiftUI/MapViewCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import MapLibre
import MapLibreSwiftDSL

public class MapViewCoordinator<T: MapViewHostViewController>: NSObject, MLNMapViewDelegate {
public class MapViewCoordinator<T: MapViewHostViewController>: NSObject, @preconcurrency MLNMapViewDelegate {
// This must be weak, the UIViewRepresentable owns the MLNMapView.
weak var mapView: MLNMapView?
var parent: MapView<T>
Expand Down Expand Up @@ -267,7 +267,7 @@ public class MapViewCoordinator<T: MapViewHostViewController>: NSObject, MLNMapV
}
}

func addLayers(to mglStyle: MLNStyle) {
@MainActor func addLayers(to mglStyle: MLNStyle) {
let firstSymbolLayer = mglStyle.layers.first { layer in
layer is MLNSymbolStyleLayer
}
Expand Down Expand Up @@ -318,7 +318,7 @@ public class MapViewCoordinator<T: MapViewHostViewController>: NSObject, MLNMapV

// MARK: - MLNMapViewDelegate

public func mapView(_: MLNMapView, didFinishLoading mglStyle: MLNStyle) {
@MainActor public func mapView(_: MLNMapView, didFinishLoading mglStyle: MLNStyle) {
addLayers(to: mglStyle)
onStyleLoaded?(mglStyle)
}
Expand Down Expand Up @@ -373,17 +373,19 @@ public class MapViewCoordinator<T: MapViewHostViewController>: NSObject, MLNMapV
}

/// The MapView's region has changed with a specific reason.
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.
MainActor.assumeIsolated {
updateViewProxy(mapView: mapView, reason: reason)
updateViewProxy(mapView: mapView, reason: reason)

guard !suppressCameraUpdatePropagation else {
return
}

updateParentCamera(mapView: mapView, reason: reason)
guard !suppressCameraUpdatePropagation else {
return
}

updateParentCamera(mapView: mapView, reason: reason)
}

// MARK: MapViewProxy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import SnapshotTesting
import XCTest
@testable import MapLibreSwiftUI

@MainActor
final class CameraPreviewTests: XCTestCase {
func testCameraPreview() {
assertView {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading