CLPlacemark returns all information except thoroughfare

I am attempting to reverse geocode a user's location in iOS 13. I am getting results as expected with the exception of the thoroughfare property.

Regrardless of the location I pick everything works as expected except this one property not returning results. Subthoroughfare returns a value when one is available which I would expect to sometimes be nil. I get the same results regardless of simulator or on device.


Has anyone experienced something like this? Other than I need to clean up my prototype code do you see anything I am doing incorrectly?


In my Geocoding function (snippet for brevity):

func geocode(
    location: CLLocation,
    completionHander: @escaping (CLPlacemark?) -> Void)
  {

... //some rate limiting stuff..

let geocoder = CLGeocoder()
    geocoder.reverseGeocodeLocation(location) { (placemark, error) in
      if error == nil {
        let firstLocation = placemark?.first
        completionHander(firstLocation)
      }else{
        completionHander(nil)
      }
    }


When I require a new location:

geocode(location: lastLocation) { placemark in
        if let place = placemark {
          let name = place.name
          let thoroughfare = place.thoroughfare
          let subthoroughfare = place.subThoroughfare
          let locality = place.locality
          let country = place.country
          
          print("name: \(name), thoroughfare: \(thoroughfare), subthoroughfare: \(subthoroughfare), locality: \(locality), country: \(country)")
          
          if let street = place.thoroughfare {
            print("throughfare: \(street)")
          } else{
            print("name: \(place.name!)")
          }
        } else {
          print("no place found")
        }
      }

Results Examples:

As mentioned I am getting the same results on device from multiple locations here in Canada, but I don't want to share my address with everyone 😉


Expect throughfare to be populated:

name: Optional("Apple Campus"), throughfare: nil, subthroughfare: Optional("1"), locality: Optional("Cupertino"), country: Optional("United States")


name: Optional("Sam H. Lawson Middle School"), thoroughfare: nil, subthoroughfare: Optional("10401"), locality: Optional("Cupertino"), country: Optional("United States")


name: Optional("10889 N De Anza Blvd"), thoroughfare: nil, subthoroughfare: Optional("10889"), locality: Optional("Cupertino"), country: Optional("United States")


Expect throughfare and subthroughfare would be empty:

name: Optional("Elbow - Sheep Wildland Provincial Park"), thoroughfare: nil, subthoroughfare: nil, locality: nil, country: Optional("Canada")


name: Optional("I-280 N"), thoroughfare: nil, subthoroughfare: nil, locality: Optional("Cupertino"), country: Optional("United States")



Thanks in advance for any assistance.

Accepted Reply

So, does it work OK now except for beta ?


If so, you should file a bug and maybe close the thread.


Good continuation.

Replies

This older thread may be useful for you.


https://forums.developer.apple.com/message/332997#332997

Thanks, I had read that thread before. It doesn't seem to address this specific issue with thoroughfare, but I will double check I'm not missing something.

Did you try with a known location, As Apple's headquarters ? thoroughfare should be “Infinite Loop”.


I tested in simulator, it works (selected Apple as location in Debug menu).


I defined in the class:


class MyLocationManager: NSObject, CLLocationManagerDelegate {
    

    private var city:String?
    private var thoroughfare:String?
    private var newLocation: CLLocation?

    static let shared = MyLocationManager()


    public func getCity()->String {
        return self.city ?? ""
    }

    public func getThoroughfare()->String {
        return self.thoroughfare ?? ""
    }


With a button to test


    @IBAction func testing(_ sender: Any) {

        print("Location: \(MyLocationManager.shared.getCity())"
        print("Thoroughfare: \(MyLocationManager.shared.getThoroughfare())")
      
    }


Which prints:

Location: Cupertino

Thoroughfare: Infinite Loop

Also tested with an address in Vancouver (enter through GPS coordinates in simulator):

W 16th Ave

Vancouver, BC, Canada

49.258022, -123.185478


I got the correct result

Location: Vancouver

Thoroughfare: W 16th Ave


In the same way, I added subThoroughfare and fot:

Location: Vancouver

Thoroughfare: W 16th Ave

SubThoroughfare: 3663


So, it could be that thoroughfare and subThoroughfare are not defined for the locations you test.

this is the result I get for the Apple Campus. Are you testing on iOS 12 or iOS 13?


name: Optional("Apple Campus"), throughfare: nil, subthroughfare: Optional("1"), locality: Optional("Cupertino"), country: Optional("United States")


I will try your a test with your code when I am back at my laptop. Thanks for your help!

I am not testing the new Apple Campus, I am testing Apple in simulator (Infinite loop).

This is their legal address:

Apple

1 Infinite Loop , CA 95014 Cupertino, California


You get the correct subThoroughfare, but nothing on thoroughfare.


Could you test as well with the GPS coordinates in Vancouver ?


This was tested with XCode 10.2 and IOS 12.2 on simulator.

I will try tomorrow on my machine running Mojave, iOS 12 / Xcode 10.


In iOS 13 Beta 3 Xcode 11 Beta 3:


When I print I description of the CLPlacemark Object I can see Infinite Loop and W 16 Ave, but I have no properties that return that data.

> print(place)


Apple Campus, Apple Campus, 1 Infinite Loop, Cupertino, CA 95014, United States @ <+37.33233141,-122.03121860> +/- 100.00m, region CLCircularRegion (identifier:'<+37.33213112,-122.02990109> radius 279.37', center:<+37.33213112,-122.02990109>, radius:279.37m)


3663 W 16th Ave, 3663 W 16th Ave, Vancouver BC V6R 3C3, Canada @ <+49.25802200,-123.18547800> +/- 100.00m, region CLCircularRegion (identifier:'<+49.25828200,-123.18531420> radius 70.75', center:<+49.25828200,-123.18531420>, radius:70.75m)


For iOS 13 / XCode 11 this is the results for the Apple Campus in the simulator:

thoroughfare: nil

subthoroughfare: 1

location: Cupertino


the location in Vancouver returns this:

thoroughfare: nil

subthoroughfare: 3663

location: Vancouver


I have a feeling this is an iOS 13 Beta issue and not something wrong with my code at this point as I get back every other property as expected.

Could be a bug in IOS or XCode, maybe in the property name ?


There is something surprising here:


In my code I use subThoroughfare (see the caps)


    public func getSubThoroughfare()->String {
       
        return self.subThoroughfare ?? ""
    }


Did you try autocompletion on place.tho


Otherwise, if it works in XCode 10, only left option is to file a bug (probably against XCode, not IOS).

Yes. Auto complete on both. I double checked both properties several times. Thanks for your help, my code works it seems on my machine not running the beta.

So, does it work OK now except for beta ?


If so, you should file a bug and maybe close the thread.


Good continuation.

Confirmed this works in iOS 12 and not iOS 13. Logging bug.

Update: without changing code or new Beta, now this works in iOS 13