MapKit MobileGestalt.c:1647: Could not retrieve region info
Asked Answered
M

4

8

I am using MapKit to show two annotations and distance between them. Everything works fine but I keep getting this error on the console. MobileGestalt.c:1647: Could not retrieve region info Anybody knows what is causing it? Could it be some permission in the .plist file

Here is full console output:

2019-11-10 00:21:41.419108+0100 Post DACH[20420:264466] Metal API Validation Enabled 2019-11-10 00:21:41.567416+0100 Post DACH[20420:264466] libMobileGestalt MobileGestalt.c:1647: Could not retrieve region info

Screenshot

My code:

struct MapView: UIViewRepresentable {
    var requestLocation: CLLocationCoordinate2D
    var destinationLocation: CLLocationCoordinate2D
    private let mapView = WrappableMapView()

    func makeUIView(context: UIViewRepresentableContext<MapView>) -> MKMapView {
        mapView.delegate = mapView
        return mapView
    }

    func updateUIView(_ uiView: MKMapView, context: UIViewRepresentableContext<MapView>) {
        let requestAnnotation = MKPointAnnotation()
        requestAnnotation.coordinate = requestLocation
        requestAnnotation.title = "Package"
        uiView.addAnnotation(requestAnnotation)

        let destinationAnnotation = MKPointAnnotation()
        destinationAnnotation.coordinate = destinationLocation
        destinationAnnotation.title = "Destiantion"
        uiView.addAnnotation(destinationAnnotation)

        let sourcePlacemark = MKPlacemark(coordinate: requestLocation)
        let destinationPlacemark = MKPlacemark(coordinate: destinationLocation)

        let directionRequest = MKDirections.Request()
        directionRequest.source = MKMapItem(placemark: sourcePlacemark)
        directionRequest.destination = MKMapItem(placemark: destinationPlacemark)
        directionRequest.transportType = .automobile

        let directions = MKDirections(request: directionRequest)

        directions.calculate { (response, error) in
            guard let directionResponse = response else {
                if let error = error {
                    print(error.localizedDescription)
                }
                return
            }

            let route = directionResponse.routes[0]
            uiView.addOverlay(route.polyline, level: .aboveRoads)
            let rect: MKMapRect = route.polyline.boundingMapRect

            uiView.setVisibleMapRect(rect, edgePadding: .init(top: 50.0, left: 50.0, bottom: 50.0, right: 50.0), animated: true)
        }

    }
}
Madson answered 9/11, 2019 at 23:30 Comment(9)
If "everything works fine" why not ignore the console messages and move on? (Especially if this message is simulator only.)Pirn
well im just worried if it could cause troubles laterMadson
Well come back when it does. We can't work on a problem that hasn't happened yet.Pirn
well it is a problem as you can see and it says: Could not retrieve region infoMadson
i am getting this same message but I am not getting the user location. Are you getting the user location? @RexhinHoxhaFermat
yes I do get the locationMadson
calculateResult closure is called in background task. Did you try to make your MKMapView updates in main queue?Shaquana
@GerdCastan yes the problem still persistsMadson
I simply ran on device and didn't find anything in console log. Maybe got something to do with Simulator.Epistasis
I
2

You might have missed setting MKMapView delegate in your code.

Try setting mapView.delegate = self in your view where you have delegate methods implemented.

Infantine answered 2/4, 2020 at 5:0 Comment(1)
I have it here ` func makeUIView(context: UIViewRepresentableContext<MapView>) -> MKMapView { mapView.delegate = mapView return mapView }`Madson
U
2

I ran into the same issue today. It appears that it's an issue with the simulator. Try running it in your device and it should work.

Understand answered 21/4, 2020 at 18:47 Comment(0)
N
0

Try this: Go to Storyboard and then open the Structure Area.

Then you drag (with ctrl) the mapview exactly on the viewController symbol (round yellow symbol) and you choose delegate.

Nahuatl answered 19/1, 2021 at 19:52 Comment(0)
C
-2

I fixed the issue by adding delegate.

Cestode answered 21/1, 2020 at 20:11 Comment(1)
This answer can be improved by adding a concrete example and explaining how or why adding a delegate fixes the issue.Experimental

© 2022 - 2024 — McMap. All rights reserved.