Catch UIViewAlertForUnsatisfiableConstraints in production

前端 未结 2 807
孤独总比滥情好
孤独总比滥情好 2021-02-19 01:25

Is it possible to catch autolayout constraint ambiguities in production – the equivalent of a UIViewAlertForUnsatisfiableConstraints breakpoint but for production a

2条回答
  •  伪装坚强ぢ
    2021-02-19 01:54

    The short answer is, this is a private API and you shouldn't be messing with it in production code…

    …at least not without knowing the related dangers:

    A) Apple will reject your app if you try to override SPIs like this in a product submitted to the app store. And if it slips through for some reason, they will catch it at some later date, and that is generally worse.

    B) Method swizzling, like @Roman mentions in his answer, often brings with it some likelihood of you destabilizing whatever you're working on further (or in the future). I still worry when I user a third party library that someone is doing something brittle like this under the hood.

    With those warnings out there, go ahead, override private methods and swizzle them to your hearts content. Just please don't ship that code.

提交回复
热议问题