How to enable spell checking in Xcode


You’re more of a video kind of person? I’ve got you covered! Here’s a video with the same content than this article 🍿


Hi 👋

This week I want to show you a feature in Xcode that's quite useful, but also quite hidden!

But first, I have a big thank you for the pretty cool indie dev project that sponsored this email: AppLayouts


Advertisement

Meet AppLayouts, an All-in-One Toolkit to Launch Your iPhone and Mac App

Extensive collection of free and premium resources to help you design and build your app for iOS and macOS in no time at all.

First 50 customers get 50% off everything, including AppLayouts Pro, with the discount code: SWIFTWITHVINCENT

👉 Launch My App 👈


Sponsors like AppLayouts really help me grow my content creation, so if you have time please make sure to check out their survey: it’s a direct support to my content creation ☺️


If you look at these few lines I've written, you're probably getting this feeling that something feels a bit off:

And you're absolutely right to have this feeling, because each of these lines actually contains a typo!

You can see that there is an extra “p” on the second line, and an extra “l” on the third line.

The problem is that, currently, there is nothing that draws our attention to these typos.

So maybe we will see them and eventually fix them, but maybe we won't.

Maybe we will get lucky and the person who reviews our code will catch the typos, but it won’t be a great use of their time.

Or maybe the mistake will simply go unnoticed and will end up being merged into the codebase.

And while they’re not a big issue, these kind of small typos definitely make the quality of a codebase slowly decrease over time.

But did you know that Xcode actually has a feature to help us find such spelling mistakes?

This feature is not widely known because it's disabled by default, but you can turn it on by going into the Edit menu then into Format, Spelling and Grammar and finally by enabling the option Check Spelling While Typing:

And as soon as the option has been enabled, all of the places where Xcode detects a spelling mistake will be underlined in red:

So now that we see where the mistakes are, it’s time for us to fix them!

For the first one, we can just right click and choose the correct alternative:

We can see that we also have the option to ignore the spelling or learn the spelling, if the typo turns out to actually be a false positive.

For the second typo, there’s a small additional subtlety: if we right click, we will see that no alternatives are offered:

It's because this time the typo is part of an identifier that contains several words.

So we need to first highlight the word that contains the mistake, right-click on the selection, and only then will we be offered with the alternatives to fix the issue:


So remember: if you want Xcode to automatically do some spell checking for you, all you need is to go into the Edit menu, Format, Spelling and Grammar and finally enable the option Check Spelling While Typing 👌

I hope you've enjoyed discovering this hidden feature of Xcode and that it will help you improve the quality of your codebase!


That’s all for this email, thanks for reading it!

If you’ve enjoyed it, feel free to forward it
to your friends and colleagues 🙌

I wish you an amazing week!

❤️

Previous
Previous

Bad practice: not using the modern formatting API

Next
Next

What’s the difference between any and Any?