From 5c0458dbf60da65aba9039ebec68840597d833db Mon Sep 17 00:00:00 2001 From: FuelBoard Contributor Date: Thu, 15 Oct 2026 21:37:41 +0100 Subject: [PATCH] Drop deprecated MapKit and ActivityKit calls, and a dead capture - RoadDistanceService builds route endpoints with MKMapItem(location:address:) instead of the MKPlacemark path deprecated in iOS 26. - LiveActivityManager updates through ActivityContent, replacing the ActivityKit update(using:) call deprecated in iOS 16.2. - The location-update hook no longer captures an unused state object; the closure body already runs on self, so behaviour is unchanged. --- FuelBoard/ContentView.swift | 2 +- FuelBoard/LiveActivityManager.swift | 2 +- FuelBoard/RoadDistanceService.swift | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/FuelBoard/ContentView.swift b/FuelBoard/ContentView.swift index 61e91f7..413e863 100644 --- a/FuelBoard/ContentView.swift +++ b/FuelBoard/ContentView.swift @@ -161,7 +161,7 @@ struct ContentView: View { } private func installLocationUpdateHook() { - locationManager.onLocationUpdate = { [weak monitor] in + locationManager.onLocationUpdate = { self.updateAlertMonitor() // The Live Activity follows the same wake-ups — this hook // fires on every fix incl. background significant-change diff --git a/FuelBoard/LiveActivityManager.swift b/FuelBoard/LiveActivityManager.swift index 2a4abd7..17b9c6f 100644 --- a/FuelBoard/LiveActivityManager.swift +++ b/FuelBoard/LiveActivityManager.swift @@ -79,7 +79,7 @@ enum LiveActivityManager { currentStartDate = nil start(attributes: attributes, state: state) } else { - Task { await current.update(using: state) } + Task { await current.update(ActivityContent(state: state, staleDate: nil)) } } } else { start(attributes: attributes, state: state) diff --git a/FuelBoard/RoadDistanceService.swift b/FuelBoard/RoadDistanceService.swift index abf9dff..3a66d83 100644 --- a/FuelBoard/RoadDistanceService.swift +++ b/FuelBoard/RoadDistanceService.swift @@ -13,6 +13,7 @@ // every row at once; the mode must also be ON for any pass to run at all. import Foundation +import CoreLocation import MapKit import UIKit import WidgetKit @@ -407,8 +408,14 @@ enum RoadDistanceService { /// Driving distance (metres) between two coordinates via Apple Maps routing. private static func roadMeters(from: CLLocationCoordinate2D, to: CLLocationCoordinate2D) async -> Double? { let request = MKDirections.Request() - request.source = MKMapItem(placemark: MKPlacemark(coordinate: from)) - request.destination = MKMapItem(placemark: MKPlacemark(coordinate: to)) + request.source = MKMapItem( + location: CLLocation(latitude: from.latitude, longitude: from.longitude), + address: nil + ) + request.destination = MKMapItem( + location: CLLocation(latitude: to.latitude, longitude: to.longitude), + address: nil + ) request.transportType = .automobile request.requestsAlternateRoutes = false do {