Search code examples
xcodelldb

How do I set an lldb breakpoint in init of objc class


I'm investigating where an offending misconfigured alertcontroller is made/presented

Terminating app due to uncaught exception 'NSGenericException', reason: 'Your application has presented a UIAlertController () of style UIAlertControllerStyleActionSheet from UP.BVTabBarViewController (). The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem. If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.

Naively I've tried this:

(lldb)  br s -n "-[UIAlertController init]"
Breakpoint 100: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.

What's the proper (working) way?


Solution

  • Unless you're doing this completely wrong, your alert controllers are all created by calling

    +[UIAlertController alertControllerWithTitle:message:preferredStyle:]
    

    However, there is really no need for this breakpoint, and it won't help you because you won't encounter the breakpoint unless you summon the particular alert that is causing the problem. Instead, just search your code globally for .actionSheet and fix the one that isn't configured as a popover.

    The rule is that on iPad all action sheets must be explicitly given a source view or source bar button item for the arrow to point to; it will be immediately obvious when you come to an action sheet for which you're not doing that.