Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Debugging: Tips and Techniques

Debugging: Tips and Techniques

Talk presented at 20º CocoaHeads meetup.

Salmo Junior

June 27, 2017
Tweet

More Decks by Salmo Junior

Other Decks in Technology

Transcript

  1. Salmo Junior iOS developer since 2011, CocoaHeads Belo Horizonte chapter

    leader, traveller and cheese addict. Senior iOS Developer at CI&T [email protected] @salmojr
  2. Advanced Breakpoints Xcode breakpoints offers us serveral great features in

    order to improve our debug experience, pushing us to another level as developers. — Add conditions and actions — Inject code instructions at runtime — Automate repetitive steps among tests — Configure breakpoints for your user — Share breakpoints with your team — Improve Exception Breakpoint usage
  3. Adding conditions and actions Conditional breakpoints will only break when

    the condition is true, and any valid code that evaluates to a boolean can be used here. You can also use any variable available on the same scope where the break point is placed.
  4. Injecting code instructions at runtime Stop adding hard-coded data during

    repetitive tests. It's dangerous. With breakpoint actions and lldb expressions, there's no need to rebuild the app.
  5. Improving Exception Breakpoint usage All Exceptions breakpoint helps stopping right

    before a crash but sometimes it is not clear. Type po $arg1 into the debug area to get the human-readable version of the error.
  6. Improving Exception Breakpoint usage Making it even better. Edit your

    breakpoint and send it to your Xcode User and it will be available for all projects.
  7. Breakpoint Shortcuts ! Add/Remove breakpoint = command + \ Edit

    breakpoint = command + option + click Breakpoints Navigator = command + 7
  8. Type Lookup The type lookup command allows you to get

    information about any type in the system. Basically it's a header-like representation that you can get right there in the debugger to remind you about the contents of the type.
  9. Watchpoints Watchpoint stops execution whenever the value of an expression

    changes, without having to predict a particular place where this may happen. watchpoint set variable self.myProperty watchpoint list watchpoint delete <number> Number of supported hardware watchpoints: 4
  10. Import Frameworks When lldb is not able to print an

    object type properly, a simple import can fix it and improve the output message.
  11. Xcode View Debugging Available since Xcode 6 this feature helps

    to analize view layers and easily identify and fix issues in an app's user interface.
  12. iOS Simulator Debug Simulator has some great features on Debug

    menu option to help you find issues on app's user interface.
  13. UIDebuggingInformationOverlay UIDebuggingInformationOverlay is a private UIWindow subclass created by Apple,

    presumably to help developers and designers debug Apple's own iOS apps. let overlay = NSClassFromString("UIDebuggingInformationOverlay") as? UIWindow.Type _ = overlay?.perform(NSSelectorFromString("prepareDebuggingOverlay")) Don't send it to production