Swift Refactoring - Debugging

Debugging implementation for Swift Local Refactoring action.

Previous - Implementation Part 2

Ninja

If you have built swift-refactor tool using ninja, then you’d have to use command line lldb debugger to debug the code. So after building swift-refactor, just run lldb in the terminal:

Next, tell the debugger which executable to debug (swift-refactor in this case):

Then set the breakpoint, e.g. for isApplicable implementation of RefactoringActionCollapseNestedIfStatement class:

Now tell lldb to run the executable with -source-filename and -pos arguments

The debugger has now stopped on line 1714 and is ready for your further input:

-> 1714

Same debug commands you’d use in Xcode UI work in command line:

LLDB

Xcode

If you choose to develop using Xcode, debugging is even easier.

Edit the swift-refactor scheme

Edit Scheme

and add launch arguments:

Launch Arguments

Set breakpoint and hit “Run”:

Breakpoint


Next - Summary

Published: February 05 2019

blog comments powered by Disqus