Post

Replies

Boosts

Views

Activity

Showing MKPolygon cause termination of app (iOS 18.0 public beta)
The code worked on previous iOS versions (16 and 17). Recently I updated an iPhone to iOS 18.0 public beta and now the code of presenting a route fails with fatal error: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MKPolygon needsElevationCorrection]: unrecognized selector sent to instance 0x303295cc0' *** First throw call stack: (0x18861f11c 0x18591e698 0x1887247d4 0x1885bc888 0x1885bc1b0 0x191b08f28 0x191b09150 0x1a86bd424 0x1a86be134 0x191a69344 0x1919d68b8 0x1919d4e90 0x1919d5078 0x1919d54b0 0x1919d59a8 0x1919cb31c 0x104655110 0x104497ca9 0x104498309 0x1043e555d 0x1043e9eb9 0x194084689) libc++abi: terminating due to uncaught exception of type NSException The code that works on previous versions: final class MapService: NSObject, MapServiceInterface, ObservableObject { var mapView = MKMapView() override init() { super.init() mapView.delegate = self setup() } func setRoute(coordinates: [CLLocationCoordinate2D]) async { let polyline = MKPolygon(coordinates: coordinates, count: coordinates.count) await mapView.addOverlay(polyline) // fails and terminates app here let edges = UIEdgeInsets(top: 10.0, left: 10.0, bottom: 12.0, right: 10.0) await mapView.setVisibleMapRect( polyline.boundingMapRect, edgePadding: edges, animated: true) } func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer { let renderer = MKPolylineRenderer(overlay: overlay) renderer.strokeColor = UIColor(.modernBlue300) renderer.lineWidth = 6 return renderer } } The view: struct MapView: View { @StateObject var viewModel = MapViewModel() var body: some View { Wrapper(view: viewModel.mapService.mapView) } }
1
0
309
Aug ’24