MKDirections often fails in iOS 9 when using geocoded end location

Originator:haugli
Number:rdar://22975872 Date Originated:5 Oct 2015
Status:Open Resolved:
Product:iOS SDK Product Version:9.0.2
Classification:Serious Bug Reproducible:Sometimes
 
Summary:
When calculating directions to an end location that was acquired from a CLGeocoder forward geocode, the request often fails with the error "Cannot locate the end location."

Removing the postal code from the geocoded address appears to solve the issue, but this is unfortunately not a viable workaround since many cities have duplicate street names, and require the postal code to differentiate the location.

The issue appears to be limited to iOS 9 (the provided demo code works fine in iOS 8).

Steps to Reproduce:
Run the code below:

    CLGeocoder *geocoder = [[CLGeocoder alloc] init];
    [geocoder geocodeAddressString:@"170 Stevenson St, San Francisco, CA 94103, USA" completionHandler:^(NSArray *placemarks, NSError *error) {
        MKPlacemark *sourcePlacemark = [[MKPlacemark alloc] initWithCoordinate:CLLocationCoordinate2DMake(37.769174, -122.423236) addressDictionary:nil];
        
        MKDirectionsRequest *request = [[MKDirectionsRequest alloc] init];
        request.source = [[MKMapItem alloc] initWithPlacemark:sourcePlacemark];
        request.destination = [[MKMapItem alloc] initWithPlacemark:[placemarks firstObject]];
        
        MKDirections *directions = [[MKDirections alloc] initWithRequest:request];
        [directions calculateDirectionsWithCompletionHandler:^(MKDirectionsResponse *response, NSError *error) {
            NSLog(@"response: %@, error: %@", response, error);
        }];
    }];

Expected Results:
The log output contains an MKDirectionsResponse object, e.g.:

2015-10-05 11:34:39.936 MapDirectionsDemo[468:361652] response: <MKDirectionsResponse: 0x17046d800>, error: (null)

Actual Results:
The log output contains an NSError object, e.g.:

2015-10-05 11:23:50.969 MapDirectionsDemo[2681:939786] response: (null), error: Error Domain=MKErrorDomain Code=5 "Directions Not Available" UserInfo={NSLocalizedFailureReason=Cannot locate the end location., MKErrorGEOError=-403, MKDirectionsErrorCode=4, NSLocalizedDescription=Directions Not Available}

Version:
iOS 9.0.2 [13A452]

Configuration:
iPhone 6 64GB Verizon, iOS 9.0.2

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!