diff --git a/Mage/DataSourceMapViewModel.swift b/Mage/DataSourceMapViewModel.swift index 6f0fb937..3e8a94d5 100644 --- a/Mage/DataSourceMapViewModel.swift +++ b/Mage/DataSourceMapViewModel.swift @@ -12,6 +12,7 @@ import DataSourceTileOverlay import DataSourceDefinition import Combine +@MainActor class DataSourceMapViewModel { var dataSource: any DataSourceDefinition var key: String @@ -45,6 +46,7 @@ class DataSourceMapViewModel { let requerySubject = PassthroughSubject() + @MainActor init( dataSource: any DataSourceDefinition, key: String, diff --git a/Mage/Localizable.xcstrings b/Mage/Localizable.xcstrings index 71ba3521..0b9aebea 100644 --- a/Mage/Localizable.xcstrings +++ b/Mage/Localizable.xcstrings @@ -276,6 +276,9 @@ } } }, + "Delete" : { + "comment" : "Alert delete button" + }, "Downloaded %@ of %@" : { "localizations" : { "en" : { diff --git a/Mage/Mixins/DataSourceMap.swift b/Mage/Mixins/DataSourceMap.swift index c83e75a1..0deedd21 100644 --- a/Mage/Mixins/DataSourceMap.swift +++ b/Mage/Mixins/DataSourceMap.swift @@ -53,7 +53,7 @@ class DataSourceMap: MapMixin { .receive(on: DispatchQueue.main) .sink { [weak self] annotations in Task { [weak self] in - await self?.handleFeatureChanges(annotations: annotations) + self?.handleFeatureChanges(annotations: annotations) } } .store(in: &cancellable) @@ -62,7 +62,7 @@ class DataSourceMap: MapMixin { .receive(on: DispatchQueue.main) .sink { [weak self] featureOverlays in Task { [weak self] in - await self?.handleFeatureOverlayChanges(featureOverlays: featureOverlays) + self?.handleFeatureOverlayChanges(featureOverlays: featureOverlays) } } .store(in: &cancellable) @@ -71,7 +71,7 @@ class DataSourceMap: MapMixin { .receive(on: DispatchQueue.main) .sink { [weak self] tileOverlays in Task { [weak self] in - await self?.updateTileOverlays(tileOverlays: tileOverlays) + self?.updateTileOverlays(tileOverlays: tileOverlays) } } .store(in: &cancellable) @@ -266,6 +266,7 @@ class DataSourceMap: MapMixin { return !inserts.isEmpty || !removals.isEmpty } + @MainActor func removeMixin(mapView: MKMapView, mapState: MapState) { mapView.removeOverlays(viewModel?.featureOverlays ?? []) mapView.removeAnnotations(viewModel?.annotations ?? []) diff --git a/Mage/Mixins/FilteredUsersMap.swift b/Mage/Mixins/FilteredUsersMap.swift index 7a597c32..94fb7e01 100644 --- a/Mage/Mixins/FilteredUsersMap.swift +++ b/Mage/Mixins/FilteredUsersMap.swift @@ -10,6 +10,7 @@ import Foundation import MapKit import MapFramework +@MainActor protocol FilteredUsersMap { var mapView: MKMapView? { get set } var filteredUsersMapMixin: FilteredUsersMapMixin? { get set } diff --git a/Mage/Observation/ObservationsMap.swift b/Mage/Observation/ObservationsMap.swift index c96fd2dd..687b7245 100644 --- a/Mage/Observation/ObservationsMap.swift +++ b/Mage/Observation/ObservationsMap.swift @@ -27,6 +27,7 @@ class ObservationsMap: DataSourceMap { @Injected(\.observationImageRepository) var imageRepository: ObservationImageRepository + @MainActor init() { super.init( dataSource: DataSources.observation diff --git a/Mage/Repository/FeatureItem/FeatureItemDefinition.swift b/Mage/Repository/FeatureItem/FeatureItemDefinition.swift index 0ea03fcb..24f8c559 100644 --- a/Mage/Repository/FeatureItem/FeatureItemDefinition.swift +++ b/Mage/Repository/FeatureItem/FeatureItemDefinition.swift @@ -13,8 +13,9 @@ extension DataSources { static let featureItem: FeatureItemDefinition = FeatureItemDefinition.definition } -class FeatureItemDefinition: DataSourceDefinition { - var mappable: Bool = true +final +class FeatureItemDefinition: DataSourceDefinition, Sendable { + var mappable: Bool = true var color: UIColor = .magenta diff --git a/Mage/Repository/Feed/FeedItemAnnotation.swift b/Mage/Repository/Feed/FeedItemAnnotation.swift index 4851a752..bf050147 100644 --- a/Mage/Repository/Feed/FeedItemAnnotation.swift +++ b/Mage/Repository/Feed/FeedItemAnnotation.swift @@ -20,7 +20,7 @@ public class FeedItemAnnotation: DataSourceAnnotation { public override var dataSource: any DataSourceDefinition { get { - DataSources.feedItem + DataSources.feedItem // ERROR: Main actor-isolated conformance of 'FeedItemDefinition' to 'DataSourceDefinition' cannot be used in nonisolated context; this is an error in the Swift 6 language mode } set { } } diff --git a/Mage/Repository/MapFeatureRepository.swift b/Mage/Repository/MapFeatureRepository.swift index fc2667ca..b0b742f4 100644 --- a/Mage/Repository/MapFeatureRepository.swift +++ b/Mage/Repository/MapFeatureRepository.swift @@ -12,9 +12,9 @@ import GeoPackage import DataSourceDefinition import MapFramework -struct AnnotationsAndOverlays { - let annotations: [DataSourceAnnotation] - let overlays: [MKOverlay] +struct AnnotationsAndOverlays: Sendable { + let annotations: [DataSourceAnnotation] // Error: Stored property 'annotations' of 'Sendable'-conforming struct 'AnnotationsAndOverlays' has non-sendable type '[DataSourceAnnotation]' + let overlays: [MKOverlay] // Error: Stored property 'overlays' of 'Sendable'-conforming struct 'AnnotationsAndOverlays' has non-sendable type '[any MKOverlay]' } protocol MapFeatureRepository { diff --git a/Mage/Routing/MageNavStack.swift b/Mage/Routing/MageNavStack.swift index d2273992..ea79469e 100644 --- a/Mage/Routing/MageNavStack.swift +++ b/Mage/Routing/MageNavStack.swift @@ -12,6 +12,7 @@ import Kingfisher import UIKit import CoreLocation +@MainActor class MageNavStack: UIViewController { @Injected(\.currentLocationRepository) var currentLocationRepository: CurrentLocationRepository diff --git a/Packages/DataSourceDefinition/Sources/DataSourceDefinition/DataSourceDefinition.swift b/Packages/DataSourceDefinition/Sources/DataSourceDefinition/DataSourceDefinition.swift index f77a0a44..65dc9033 100644 --- a/Packages/DataSourceDefinition/Sources/DataSourceDefinition/DataSourceDefinition.swift +++ b/Packages/DataSourceDefinition/Sources/DataSourceDefinition/DataSourceDefinition.swift @@ -1,6 +1,7 @@ import UIKit import SwiftUI +//@MainActor public protocol DataSourceDefinition: ObservableObject { var mappable: Bool { get } var color: UIColor { get } diff --git a/Packages/MapFramework/Sources/MapFramework/DataSourceAnnotation.swift b/Packages/MapFramework/Sources/MapFramework/DataSourceAnnotation.swift index 69277bce..e7f4429c 100644 --- a/Packages/MapFramework/Sources/MapFramework/DataSourceAnnotation.swift +++ b/Packages/MapFramework/Sources/MapFramework/DataSourceAnnotation.swift @@ -36,6 +36,7 @@ public class UnknownDefinition: DataSourceDefinition { private init() { } } +//@MainActor open class DataSourceAnnotation: NSObject, MKAnnotation, Identifiable, DataSourceIdentifiable { static func == (lhs: DataSourceAnnotation, rhs: DataSourceAnnotation) -> Bool { lhs.id == rhs.id diff --git a/Packages/MapFramework/Sources/MapFramework/MapMixin.swift b/Packages/MapFramework/Sources/MapFramework/MapMixin.swift index f5e4f542..f84314e2 100644 --- a/Packages/MapFramework/Sources/MapFramework/MapMixin.swift +++ b/Packages/MapFramework/Sources/MapFramework/MapMixin.swift @@ -12,6 +12,7 @@ import CoreGraphics import DataSourceTileOverlay import SwiftUI +@MainActor public protocol MapMixin { var uuid: UUID { get } func cleanupMixin() @@ -26,7 +27,7 @@ public protocol MapMixin { touchPoint: CGPoint ) async -> [String: [String]] - func setupMixin(mapView: MKMapView, mapState: MapState) + func setupMixin(mapView: MKMapView, mapState: MapState) func removeMixin(mapView: MKMapView, mapState: MapState) func updateMixin(mapView: MKMapView, mapState: MapState) } diff --git a/Packages/MapFramework/Sources/MapFramework/MapProtocol.swift b/Packages/MapFramework/Sources/MapFramework/MapProtocol.swift index 85e6fb9b..45a18494 100644 --- a/Packages/MapFramework/Sources/MapFramework/MapProtocol.swift +++ b/Packages/MapFramework/Sources/MapFramework/MapProtocol.swift @@ -8,6 +8,7 @@ import Foundation +@MainActor protocol MapProtocol { var mixins: MapMixins { get set } var mapState: MapState { get } diff --git a/Packages/MapFramework/Sources/MapFramework/MapRepresentable.swift b/Packages/MapFramework/Sources/MapFramework/MapRepresentable.swift index 3b11ee62..42711023 100644 --- a/Packages/MapFramework/Sources/MapFramework/MapRepresentable.swift +++ b/Packages/MapFramework/Sources/MapFramework/MapRepresentable.swift @@ -11,6 +11,7 @@ import SwiftUI import MapKit import MAGEStyle +@MainActor public struct MapRepresentable: UIViewRepresentable, MapProtocol { var notificationOnTap: NSNotification.Name = .MapItemsTapped var notificationOnLongPress: NSNotification.Name = .MapLongPress