allElementsBoundByIndex fails where firstMatch succeeds

Very strange issue happening for me on iPhone X 11.2 Simulator. This doesn't seem to occur on iPhone SE nor iPad Mini 11.2 Simulators.


let searchPredicate: NSPredicate = NSPredicate(format: "identifier CONTAINS[cd] %@ || label CONTAINS[cd] %@", searchString, searchString)
let firstMatch = XCUIApplication().descendants(matching: .other).matching(searchPredicate).firstMatch
let allMatches = XCUIApplication().descendants(matching: .other).matching(searchPredicate).allElementsBoundByIndex


XCUIApplication().debugDescription shows multiple XCUIElements of type .other which match the searchPredicate, as designed.

firstMatch returns a proper XCUIElement, as verified in the above debugDescription.

allElementsBoundByIndex returns nil, even though firstMatch worked and we should have at least gotten an array with one element.


This fails on iPhone X 11.2 Simulator consistently... except when it works perfectly for mysterious reasons.