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

Debugging in Xcode

Debugging in Xcode

Debugging in Xcode
Speaker: Hrishikesh Devhare

No developer 👨‍💻 is excited when someone comes to them with a list of bugs. 😒 But everyone has to 🔍debug the code. Let’s discuss hidden gems 💎in Xcode’s breakpoints, watchpoints and visual debugger and LLDB to squash those bugs 🔨and ship 🛳 your app. 😇

Talk Video: https://www.youtube.com/watch?v=fkoC0qyQnGg

Talk presented at Swift Mumbai Chapter 8 Meetup at Eros Now on April 13, 2019
https://www.meetup.com/Swift-Mumbai/events/259194853/

Twitter: https://twitter.com/hrishiD
Presented at Swift Mumbai Chapter 8 Meetup hosted by Eros Now
https://www.meetup.com/Swift-Mumbai/events/259194853/

Swift India

April 13, 2019
Tweet

More Decks by Swift India

Other Decks in Technology

Transcript

  1. Finds following types of Bugs • Logic Flaws • Memory

    Management flaws • Dead Store • API Usage flaws Static Analyser
  2. Static Analyser • Build Settings • Won’t cover all scenarios

    • Possibility of false positive • WWDC 2016 Session 412 
 Thread Sanitizer and Static Analysis
  3. • Main Thread Sanitiser • Thread Sanitiser • Address Sanitiser

    • Undefined Behaviour Sanitiser Run Time Tools
  4. • UI Updates on Main Thread • Creation and removal

    of UI Elements • Ready to use • WWDC 2017 Session 404
 Finding Bugs Using Xcode Runtime Tools Main Thread Sanitizer
  5. Thread Sanitiser • Detects Data race • Threading bugs e.g.

    uninitialized mutexes and thread leaks • Use Dispatch API • WWDC 2016 Session 412 
 Thread Sanitizer and Static Analysis
  6. Thread Sanitiser Limitations • Supported only for 64-bit macOS and

    64-bit iOS and tvOS simulators. • watchOS is not supported • Can not use on when running apps on a device. • Performance Impact • increase in memory usage by 5⨉ to 10⨉ • CPU slowdown of 2⨉ to 20⨉
  7. • Detects memory corruption • Use ARC • WWDC 2015

    Session 413 
 Advanced Debugging and the Address Sanitizer Address Sanitiser
  8. • Dividing by zero • Loading memory from a misaligned

    pointer • Dereferencing a null pointer • WWDC 2017 Session 404
 Finding Bugs Using Xcode Runtime Tools Undefined Behaviour Sanitiser
  9. Swift Objective C Require 
 recompilation? Main Thread Sanitizer ✅

    ✅ ❌ Thread Sanitizer ✅ ✅ ✅ Address Sanitizer ✅ ✅ ✅ Undefined Behaviour
 Sanitizer ❌ ✅ ✅ Run Time Tools
  10. • UserDefaults • Image • Notifications • Storyboard / XIB

    files • Dictionary keys • Bundle resources Enums for string constants
  11. Recap ✅ Use Static Analyser ✅ Runtime tools for debug,

    test configuration. ✅ Asserts to validate app data state. ✅ Use Enums.