'MapBox SearchUI breaking when displaying Search Results

So I've worked on this App which should display a map, add annotations on coordinates found by Mapbox SearchUI, and start Navigating there when requesting it. It all worked fine until I opened xcode and tried to build today. I have the impression that MapBox updated Mapbox SearchUI (I am calling pod 'MapboxSearchUI', ">= 1.0.0-beta", "< 2.0" and it seems like XCode then uses 1.0.0-beta.2). Everything still works except one breaking thing: when trying to search stuff in the searchUI search bar, the app cant display the results, resulting in a timeout.

2021-10-13 13:51:15.300321+0200 APP[10454:5269100] [LayoutConstraints] Changing the translatesAutoresizingMaskIntoConstraints property of a UITableViewCell that is managed by a UITableView is not supported, and will result in incorrect self-sizing. Cell: <MapboxSearchUI.SearchSuggestionCell: 0x1138f7000; baseClass = UITableViewCell; frame = (0 0; 442 68); clipsToBounds = YES; autoresize = RM+BM; layer = <CALayer: 0x280d99980>> 2021-10-13 13:51:15.300463+0200 APP[10454:5269100] *** Assertion failure in -[MapboxSearchUI.SearchSuggestionCell _setHostsLayoutEngine:], NSLayoutConstraint_UIKitAdditions.m:3806 2021-10-13 13:51:15.301220+0200 APP[10454:5269100] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Must translate autoresizing mask into constraints to have _setHostsLayoutEngine:YES.'

Seems like XCode has trouble with MapBox's Layout for the results. This explains why searching from shortcuts such as Gas stations work fine since they don't need to display search results in the searchUI, doing it on the map instead.

Does anyone know how to work around this? Or is there a way to know what version exactly I was using a few weeks back? The weird thing is that I did not update the pods or mess with other parts of the project. It was on hold there and now it won't work anymore.

Thanks!



Solution 1:[1]

I've recently come across the same error message (and visual effect) in a codebase which does not use MapBox. The error started to occur only when the project was built using Xcode 13/iOS 15 instead of Xcode 12/iOS 14 (which was used before). The error only occurred on simulators/devices running iOS 15, not on iOS 14.

The codebase was, as the error message suggests, setting the translatesAutoresizingMaskIntoConstraints = false in multiple UITableViewCell's awakeFromNib() methods. Removing the line caused the error message to disappear and the contents to be displayed correctly on both, iOS 14 and iOS 15.

In your case, this will likely have to be addressed by the team at MapBox and a new SDK version would have to be provided including the change.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Benjamin