The code below runs perfectly in xCode 7.3 and on iOS 9 devices. However, when run on an iOS 10 device, the MKDirections response will not display the route step instruction.
Steps to Reproduce:
-
Run the same code in attached file in xCode 7.3 with an iOS 9 Simulator and see steps printing in console
-
Run the same code in attached file in xCode 7.3 with an iOS 10 device attached and see that the steps are NOT printing.
-
Run code in xCode 8.0 with iOS 10 Simulator device and see that the steps are NOT printing.
No error is displayed, only an empty string
I have submitted a bug report to Apple in Bug Reporter as it was being displayed in beta 2 and it has not been fixed in beta 3. This will break all apps using the instructions attribute. This includes an app I have on the App Store now. I have never submitted a bug report before, so I could have done something wrong. No response from Apple. I would be forever grateful if someone else could test and see if they get the same result.
import UIKit
import MapKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let request = MKDirectionsRequest()
request.source = MKMapItem(placemark: MKPlacemark(coordinate: CLLocationCoordinate2D(latitude: 49.3447999, longitude: -123.0828718), addressDictionary: nil))
request.destination = MKMapItem(placemark: MKPlacemark(coordinate: CLLocationCoordinate2D(latitude: 49.3241914, longitude: -123.0794145), addressDictionary: nil))
request.transportType = .Automobile
let directions = MKDirections(request: request)
directions.calculateDirectionsWithCompletionHandler {response, error in
guard let unwrappedResponse = response else { return }
for route in unwrappedResponse.routes {
for step in route.steps {
print("Instruction: \(step.instructions)")
}
}
}
}
}