Closed TBulicek closed 6 years ago
Thanks for providing a sample. I can duplicate the issue on a device in release mode.
From console
default 09:37:15.755336 -0400 SearchBarTest Call host has no calls
default 09:37:15.759183 -0400 SearchBarTest -[UIKit_UISearchController___Xamarin_UISearchResultsUpdating updateSearchResultsForSearchController:]: unrecognized selector sent to instance 0x281b26ac0
default 09:37:15.759264 -0400 SearchBarTest
Unhandled Exception:
Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[UIKit_UISearchController___Xamarin_UISearchResultsUpdating updateSearchResultsForSearchController:]: unrecognized selector sent to instance 0x281b26ac0
Note that iOS version specific issues (things that only happens in some iOS version) are often bugs inside iOS itself for which there's not much we can do.
It does seems to be an issue on our side. I'll have to see why it works with older iOS versions...
So we're not preserving a method that is called (from iOS / native) at runtime.
Workaround: Change
- public partial class ViewController : UITableViewController
+ public partial class ViewController : UITableViewController, IUISearchResultsUpdating
and add
public void UpdateSearchResultsForSearchController (UISearchController searchController)
{
throw new NotImplementedException ();
}
to your project. That will hint the linker that UpdateSearchResultsForSearchController
and the related selector needs to be preserved.
Still unsure why it would work before iOS 12 (I'll test that in parallel with my fix).
I get the same crash on iOS 9.3.5 so I'll assume it's not related to the iOS version but is the issue I identified earlier. It's possible that, in a larger application (not the test case) something else makes the linker preserve the method/selector so it does not show up.
Steps to Reproduce
Expected Behavior
Update action gets invoked on touch.
Actual Behavior
App crashes on touch in UISearchBar.
Additional important info: Only crashes on iOS 12. Similar crash in Bug 24505. App does not crash without "SetSearchResultsUpdater" Working "workaround": sc.SearchBar.TextChanged event handler.
Environment
Build Logs
buildLog.txt
Example Project (If Possible)
SearchBarTest.zip