I tried
self.searchBar.accessibilityTraits = .searchField
self.searchBar.accessibilityIdentifier = "mySearchBar"
in UISearchController
but it does not work, I need the accessibilityIdentifier to be visible in Appium for UI testing
The solution is to set
self.searchBar.isAccessibilityElement = true