mapbox / mapbox-navigation-ios

Turn-by-turn navigation logic and UI in Swift on iOS
https://docs.mapbox.com/ios/navigation/
Other
861 stars 314 forks source link

Remove optional dependency on MapboxGeocoder.swift for search on CarPlay #2285

Closed 1ec5 closed 3 years ago

1ec5 commented 4 years ago

When installing MapboxNavigation using CocoaPods, any functionality guarded by canImport(MapboxGeocoder) is unavailable, namely RecentItem and CarPlaySearchController’s conformance to the CPSearchTemplateDelegate protocol: https://github.com/mapbox/mapbox-navigation-ios/issues/1839#issuecomment-438789900. Developers using CocoaPods are forced to copy the entirety of CarPlaySearchController+ CPSearchTemplateDelegate.swift and RecentItem.swift into their applications, plus the carplay_search asset, in order to implement a search interface powered by MapboxGeocoder.swift in CarPlay.

Until the underlying issue with CocoaPods is resolved or worked around, we can streamline the steps to implement that MapboxGeocoder.swift-powered interface. CarPlaySearchControllerDelegate should be more granular, with hooks for kicking off a geocoding request and receiving the response. Most of the implementation can remain in the navigation SDK, but it should rely on types vended by required libraries, so any GeocodedPlacemark usage should be replaced by Waypoint or perhaps an MGLPointAnnotation subclass akin to MapKit’s MKMapItem class.

The developer would need to write some minimal code to configure the search and convert its responses into waypoints, but these are exactly the hooks a developer would want for customization purposes anyways. We would need to document appropriate default options to avoid surprises like a missing focalLocation or a missing locale. In the future, once we implement a preview view controller (#808), it may make sense to formally depend on MapboxGeocoder.swift and vend those defaults at that time.

/cc @mapbox/navigation-ios @mapbox/search-sdk

1ec5 commented 3 years ago

The dependency will be completely removed between #2999 and #3183.