In my last post I discussed my experience with my first ever WWDC lab. This is a collection of some of the tips I learned about Xcode during that lab.
These would have made a great blog post but this blog didn’t exist then so c’est la vie. Here’s what I Tweeted about the tips at the time. Note: A lot of these Tweets have multiple parts so if one interests you make sure you view the full Twitter thread attached to that Tweet!
If you haven’t seen the comments that Paris Xavier Pinkney added in Tip #9 make sure to check them out. Next level debugging tips!
Tip #1 - Minimap
The minimap can give you an overhead view of your code that lets you quickly jump to a different section.
Xcode Tip #1: This button is something I don't think I've ever pressed. Under the menu it presents is something called the Minimap. pic.twitter.com/zq0tUIhXUI
— Chris Wu (@MuseumShuffle) June 10, 2021
Tip #2 - Edit in Scope
You can easily rename something where only relevant items are renamed.
Xcode tip #2: "Edit all in scope" is your friend. Here I have various things called/printing some form of helloworld. pic.twitter.com/kKmck5MHRW
— Chris Wu (@MuseumShuffle) June 10, 2021
Tip #3 - Code folding ribbon
Very few things I’ve posted about on Twitter have gotten as much attention as this post about Xcode’s code folding ribbon. I mentioned this during my lab and one of the engineers said she had worked on this feature! 😃 It is so handy.
When you need to cut/paste code in Xcode the code folding ribbon is incredibly handy. If you collapse the things you want to move it makes it trivial to select them for a cut. pic.twitter.com/2WaYaccg82
— Chris Wu (@MuseumShuffle) March 29, 2021
Tip #4 - Rename controls
Xcode tip #4: When you do a 'rename' (one way to do that is Editor->Refactor->Rename) there are controls off to the side that you can click on for more control over what is/isn't renamed. You can even control what happens to matches in comments! 🤯 pic.twitter.com/wk978mRoYZ
— Chris Wu (@MuseumShuffle) June 11, 2021
Tip #5 - Control over where files open.
This one eliminated much frustration from me.
Xcode tip #5: My workflow is that I like to have a split view where the code I'm working on is on the left and code I'm using for reference is on the right. I constantly am opening files on the wrong side. Under nav pref you can set files to always open in the primary editor. 🤯 pic.twitter.com/PmIg1CCK0N
— Chris Wu (@MuseumShuffle) June 11, 2021
Tip #6 - Keyboard shortcuts for jumping to Xcode different areas
Xcode tip #6 In this toolbar you can use cmd-1 to select the project navigator, cmd-2 to select the source control nav (the one next to it), etc. For someone like me that enjoys using the mouse less because of Vim it is criminal to not be using these. pic.twitter.com/o1z62irNUJ
— Chris Wu (@MuseumShuffle) June 11, 2021
Tip #7 - Keyboard shortcut to jump to parts of the current file
Xcode tip #7: In looking in my notes it looks like I did write down that ctrl-6 is a great shortcut to pull up relevant parts of your file. @javierdemartin pointed out you can start typing and narrow down the results! pic.twitter.com/pnYHHGKSV2
— Chris Wu (@MuseumShuffle) June 11, 2021
Tip #8 - Pause your app for debugging
Xcode tip #8 This is the button you hit to continue program execution when your code has stopped at a breakpoint. I never noticed that when you do that it becomes a "pause" symbol. You can pause your app at any time. You can't interact with the UI but you can debug. pic.twitter.com/Xq54Jqi1YE
— Chris Wu (@MuseumShuffle) June 12, 2021
Tip #9 - Fine control over breakpoint actions
Tying sounds to a debugging breakpoint can have benefits you might not have considered.
Xcode tip #9 Double clicking a breakpoint is where you can get fine control over it. Something I hadn't considered doing is setting a breakpoint for a "this should never happen" condition and tie a sound to it. If you hear it investigate! pic.twitter.com/DYDZJt6Odh
— Chris Wu (@MuseumShuffle) June 12, 2021
This Tweet started a conversation where Paris showed us some fascinating use cases for this.
The audio debugging is great for investigating race conditions and other tricky concurrency bugs that you wouldn’t catch by throwing an exceptions prior to structured concurrency.
— Paris Xavier Pinkney (@pxpgraphics) June 12, 2021
Something I’ve used in the past is one higher pitched sound for a getter and another lower pitched sound for a setter to detect the source and timing of a data race.
— Paris Xavier Pinkney (@pxpgraphics) June 12, 2021
Get: “beep”
Set: “boop”
Works great with logging when actually trapping the bp causes the behavior to change
Tip #10 - Environment Overrides
Xcode tip #10 I've never noticed this button either when debugging. It gives you control over Environment Overrides. You could easily see what your UI is like with large dynamic fonts, for example. pic.twitter.com/ZIzPSudlju
— Chris Wu (@MuseumShuffle) June 12, 2021
Conclusion
If this post was helpful to you I’d love to hear about it! Find me on Twitter.