Jan 23, 2022 ⋅ 1 min read
Typos in Xcode – Never Again!
Typos in code can always happen, we’re all human. Most of us aren’t native speakers and write their code in English anyway. But typos in code can be annoying. Other developers will eventually stumble across them and can get distracted reading the code. At best, they will fix the typo, but it will be bit of work to make the change, commit the code etc.
It would be better not to introduce typos in the first place, right? Someone should be alerting us to typos as we write the code! Well, Xcode can actually do that!
How to activate the setting
- Open Xcode
- Have your cursor in a file with text (otherwise you can’t activate the setting and it will be greyed out)
- Activate the setting in Xcode’s system menu with:
Edit > Format > Spelling and Grammar > Check Spelling While Typing
🥳 Benefits
- This is not limited to comments and will also work in variable/function/type names, even in camelCase syntax.
- It’s especially useful if your hardware keyboard has some issues and keys are stuck while typing and you get repetitive characters without recognizing it.
- It even works with multiple languages if the setting for it is activated (check it in
Preferences > Spelling
). - You and your colleagues don’t have to make others aware of typos anymore.
- If you use some idioms or specific words in your company, which are spelled correctly, but Xcode is complaining about them, you can let the system learn a word, so you’re not seeing the red underline anymore.