Group Group Group Group Group Group Group Group Group

Chapter 5: Symbolic breakpoint doesn't trigger

Hello,

When creating a symbolic breakpoint

Signals.MasterContainerViewController.viewDidLoad() -> ()

Then Build and Run the app, Xcode doesn’t trigger it. How come or what have I done wrong?

It seems that I have done it correctly. Screenshot 2020-02-06 at 15.25.55

Hi @sparklydust

You can not use Swift code while working with Symbolic Breakpoints so in order to make it work you’ll have to change the symbol to Objective-C:

-[UIViewController viewDidLoad]

This will catch the viewDidLoad event for all UIViewController’s so in order to get the controller that you want you need to add a condition to the Symbolic Breakpoint to only trigger when it matches your controller.

This is a little tricky since you are trying to call a Swift class from Objective-C but you can achieve that with NSClassFromString:

(BOOL)[$arg1 isKindOfClass: (id)NSClassFromString(@"Signals.MasterContainerViewController")]

And now your Symbolic Breakpoint should be working as expected

Hope it helps!
Good luck :]

Thank you for your answer. It did trigger when writing the symbolic breakpoint your way. But this might be an error in the book then since it is asked to write the breakpoint using Swift Code…

It is even asked to do a symbolic breakpoint using Swift in Chapter 6, but still, it doesn’t trigger. You can notice the result on the book example Debug Navigator that it is a Swift code and not an Objective-C. I might have misunderstood a point somewhere…

Screenshot 2020-02-10 at 16.51.22

Ohhh, wasn’t aware that your question was in specific to the Advanced Apple Debugging book :dizzy_face:

Tried that part and isn’t working for me either,
the last version of this book is v3.0.0 for Xcode 10/Swift 4.2
maybe updates to Xcode 11.3/Swift 5 have changed this section

Sorry not to be helpful this time
Good Luck :]

@lolgrep Can you please help with this when you get a chance? Thank you - much appreciated! :]

I find that I can use

Signals.MasterContainerViewController.viewDidLoad

at first p self wouldn’t work yet,

YAY debugging <Signals.MasterViewController: 0x7fc739c11b30>
(lldb) p self
error: <EXPR>:3:1: error: cannot find 'self' in scope
self
^~~~

But if I step a few times to finally get to the Swift code, p self would start working

->  0x1077a8286 <+38>: call   0x1077a8160               ; Signals.MasterContainerViewController.viewDidLoad() -> () at MasterContainerViewController.swift:42

Screen Shot 2020-07-05 at 14.59.33

This topic was automatically closed after 166 days. New replies are no longer allowed.