Solution: don't use brittle index-based xpath. Instead use shorter xpath statements that utilize a unique attribute. For example, an iOS Cancel button may have a valid xpath of:
//UIAButton[@name="Cancel"]
It's unlikely the element type UIAButton is changing, nor is it likely the name/text of the button is changing. Thus that xpath will be robust and reliable. Assuming there's not multiple Cancel buttons on the same screen. Then you need to come up with some other unique xpath such as including the parent element in the xpath such as:
//UIATableRow/UIAButton[@name="Cancel"]