Columns Breakpoints Xcode 13, WWDC 21
Hi Folks,
Hope everyone enjoyed the week full of announcements like any other previous years with new iOS, Mac, and Watch OS and Developer tools.
Let us talk about one important feature which I was personally looking forward to since frequent usage of HighOrderFunctions, nesting of closures in Swift. So finally in recent WWDC -2021, Apple Engineers introduced the concept of Column Breakpoint. I understand this specific feature is not one of the core announcements of WWDC -21 but yes in my opinion it's a blessing in disguise for a developer.
What's the need?
The initial row line breakpoint was not granular enough. For example, while debugging some high-order function or looping over a sequence become repetitive and comparatively consumes more of the developer's precious time.
NOTE : This feature in available from Xcode 13
OK Got it, Enough of the theory
Let’s put it into work?
Please follow the following steps.
- Press Command (⌘) + Click on the expression where you want to add column breakpoint.
- An action popover appears → Select → Set Column Breakpoint
For example please check the image below →
At Line 70 a column breakpoint is set on expression convertedToVolume fucntion.
Operations on column breakpoints —
- Enable/disable column breakpoints like the line breakpoint, by clicking on them.
- Likewise line breakpoint, drag, and release in order to remove the column breakpoint.
- We can also open the breakpoint editor by double-clicking on the same.
- The column breakpoint is also visible in the breakpoint navigator in Xcode.
How to know the code execution is at a halt due to column breakpoint?
When column breakpoint halts the code execution, Xcode demarcates it with the light green color on the line where the code is halted. And there is a green highlight underline on the expression on which the column breakpoint was set.
For example please check the image below →
Line 70 is highlighted and convertedToVolume expression is underline and highlighted in green color
Common Usage
A very common scenario showcasing the best usage of column breakpoint.
Multiple closures in a single line of swift code. Please check the below image for reference.
Using column breakpoint to check $0 value
Reference — WWDC -2021 https://developer.apple.com/videos/play/wwdc2021/10209/
Thank you for reading the article. Please provide your valuable feedback/comments for improving the article.
Keep learning and keep growing.
Cheers !!!