Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
13 changes: 4 additions & 9 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,7 +21,9 @@ 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"),
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