Gems » https://developer.apple.com/videos/play/techtalks-ios-7/8/ » CocoaConf Boston 2014: Effective Xcode: Tips & Techniques by Laura Savino » Notes from Xcode Walkabout: https://gist.github.com/ lsavino/860a5bfa47c6834e890b » Leveling Up: Walk away having learned at least one thing Advanced Debugging with Xcode 3/53
":##" to jump to a specific line (ViewCon:12) » All symbols—classes, structs, enums, functions, etc. » Matches across symbol names in sequence: UINC will find UINavigationController Advanced Debugging with Xcode 5/53
memory » Use Your Loaf: Xcode Visual Memory Debugger (source of the screen shots) » https://useyourloaf.com/blog/xcode-visual-memory-debugger/ » Pete the Developer: iOS — Identifying Memory Leaks using the Xcode Memory Graph Debugger » http://petethedeveloper.com/post/identityingmemoryleaksgraphdebugger/ Advanced Debugging with Xcode 15/53
languages with long words without breakable space » "cut" in German is ausschneiden (for example) » -NSShowNonLocalizedStrings YES » Shows text from non-localized strings IN ALL CAPS » Both are also available from the Options tab in Edit Scheme… Advanced Debugging with Xcode 17/53
French: » -AppleLanguages (fr) » -AppleLocale fr_CA » Use Your Loaf: Using Launch Arguments To Test Localizations » https://useyourloaf.com/blog/using-launch-arguments- to-test-localizations/ » Both are also available from the Options tab in Edit Scheme… Advanced Debugging with Xcode 18/53
to debug » Set a conditional breakpoint with an action of "Log Message" » Check "Automatically continue after evaluating actions" » No need to recompile and re-run Advanced Debugging with Xcode 23/53
» Save an All Exceptions breakpoint in user space » In LLDB, po $arg1 to print the exception » Symbolic breakpoints can break inside Apple's frameworks Advanced Debugging with Xcode 25/53
On pause, use the call stack to find where the change occurred » Watchpoints can be managed from LLDB Watchpoint 1 hit: old value: true new value: false Advanced Debugging with Xcode 26/53
the console log » Look for the (lldb) prompt » Enter help for a full list of commands » Awesome way to test a specific line of code in context » Examine contents of complex data structures » Test and tweak an expression to get the correct syntax » See if an expression is returning what you expect » http://lldb.llvm.org Advanced Debugging with Xcode 28/53
» Displays any returned value with formatting controlled by the type's author (debugDescription) (lldb) po anInt 10 (lldb) po anObject <UIView: 0x7fa331606770; frame = (0 0; 0 0); layer = <CALayer: 0x604000030b00>> Advanced Debugging with Xcode 30/53
frame » Defaults to all arguments and local variables in scope » Names of argument, local, file static and file global variables can be specified » Children of aggregate variables can be specified such as var->child.x (lldb) fr v anInt (Int) anInt = 10 (lldb) fr v anObject (UIView) anObject = 0x00007fa331606770 { UIKit.UIResponder = { baseNSObject@0 = { isa = UIView } } } Advanced Debugging with Xcode 31/53
» Displays any returned value with LLDB's default formatting » Can affect the current context and change variable values (lldb) p varInt (Int) $R0 = 12 (lldb) expr varInt = 15 (lldb) p varInt (Int) $R2 = 15 Advanced Debugging with Xcode 32/53
as (short) text » Much more reliable from the variables pane than hovering over a symbol in code » You can Quick Look a view and see a preview of it, too! Advanced Debugging with Xcode 33/53
height.active = true 2018-03-27 11:44:50.061399-0400 Example[44373:13943052] [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. ( "<NSLayoutConstraint:0x604000280aa0 UILabel:0x7f9098405820'Label'.centerY == UIView:0x7f9098405520.centerY (active)>", "<NSLayoutConstraint:0x604000280b40 UILabel:0x7f9098405820'Label'.top == UILayoutGuide:0x6040007ac5c0'UIViewSafeAreaLayoutGuide'.top + 200 (active)>", "<NSLayoutConstraint:0x604000280050 'LabelHeight' UILabel:0x7f9098405820'Label'.height == 20 (active)>", "<NSLayoutConstraint:0x608000286680 'UIView-Encapsulated-Layout-Height' UIView:0x7f9098405520.height == 812 (active)>", "<NSLayoutConstraint:0x604000280b90 'UIViewSafeAreaLayoutGuide-top' V:|-(44)-[UILayoutGuide:0x6040007ac5c0'UIViewSafeAreaLayoutGuide'] (active, names: '|':UIView:0x7f9098405520 )>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x604000280050 'LabelHeight' UILabel:0x7f9098405820'Label'.height == 20 (active)> Advanced Debugging with Xcode 38/53
runs layout x times before throwing an error » -UIViewLayoutFeedbackLoopDebuggingThreshold x » Replace UI with NS for macOS » Provides layout detail for each pass // don't actually do this override func viewDidLayoutSubviews() { view.setNeedsLayout() } Advanced Debugging with Xcode 40/53
retain/release for objects » Once opened, click the red record icon on the top left to start capturing results » Switch to your app and use it to capture activity » Pause when you no longer need to capture Advanced Debugging with Xcode 44/53
Development Gems » https://developer.apple.com/videos/play/techtalks-ios-7/8/ » CocoaConf Boston 2014: Effective Xcode: Tips & Techniques by Laura Savino » Notes from Xcode Walkabout: https://gist.github.com/lsavino/860a5bfa47c6834e890b » Appdevcon 2018: Learn to Debug Like a Pro by Paul Hudson (@twostraws) » https://speakerdeck.com/twostraws/learn-to-debug-like-a-pro » NSHipster: Launch Arguments & Environment Variables » http://nshipster.com/launch-arguments-and-environment-variables/ » Use Your Loaf: Using Launch Arguments To Test Localizations » https://useyourloaf.com/blog/using-launch-arguments-to-test-localizations/ Advanced Debugging with Xcode 49/53
» https://developer.apple.com/library/content/documentation/Performance/Conceptual/ ManagingMemory/Articles/MallocDebug.html » @johnsundell: https://twitter.com/johnsundell/status/973273054699773953 » James Dempsey and the Breakpoints: Backtrace » https://itunes.apple.com/us/album/backtrace/id926558924?uo=4&at=11lpkp&ct=09 » The LLDB Debugger » http://lldb.llvm.org » Why The Failure, Auto Layout » http://www.wtfautolayout.com Advanced Debugging with Xcode 50/53
https://developer.apple.com/library/content/technotes/tn2239/_index.html » Technical Note TN2124: Mac OS X Debugging Magic » https://developer.apple.com/library/content/technotes/tn2124/_index.html » Debugging with Xcode: Specialized Debugging Workflows » https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/ debugging_with_xcode/chapters/special_debugging_workflows.html » Use Your Loaf: Xcode Visual Memory Debugger » https://useyourloaf.com/blog/xcode-visual-memory-debugger/ » Pete the Developer: iOS — Identifying Memory Leaks using the Xcode Memory Graph Debugger » http://petethedeveloper.com/post/identityingmemoryleaksgraphdebugger/ Advanced Debugging with Xcode 52/53