I'm currently developing an app using SwiftUI with Xcode 15 targeting iOS 17, and I'm running into an issue with the MKLocalSearchCompleter. I'm trying to implement a search functionality where the user can type in a query, and the app suggests relevant locations (e.g., typing "Balt" should suggest "Baltimore, MD"). However, the search results are not being displayed correctly in my app. The immediate goal here is for the app to present an option that matches the users destination, to then provide a choice of routes each route will then display locations from my json file that are along the route. When the user makes the final selection from the options presented by the autocompleter the map will pan out to show both the current location and the destination- and if there is a choice of routes they would be highlighted.
Here are the steps I've taken:
Implemented the MKLocalSearchCompleterDelegate to handle search suggestions. Configured resultTypes to include .address. Used the onChange modifier to trigger searches when the search text changes. Set up proper bindings and state management for the search term and results. The app seems to initiate the search, but the results aren't being populated as expected. Instead, I get "Displaying search results: 0" in the debugger, and no suggestions are shown on the device screen. Additionally, I'm seeing errors related to invalid numeric values being passed to CoreGraphics API in the debugger, which might be related to this issue.
Has anyone else encountered this issue, or can anyone suggest what might be going wrong? Is there a known issue with MKLocalSearchCompleter in iOS 17 or any configuration that I might be missing? Here is the file that attempts to perform the action: