Did you know that Xcode can spell check your code and comments? Based on my experience working on large teams and large Xcode projects, this is a little-known feature. I routinely find spelling errors, not only in code comments but in symbol names. For the latter, this is particularly frustrating when a misspelled symbol is widely used because correcting that error — a rename that affects a substantial portion of the codebase — produces a large diff. Once you notice that your entire team has been passing around a “databaesQuery” for six months, it will drive you insane until fixed.

On large teams, large diffs are difficult to get reviewed. But more importantly, the probability for merge conflicts is high. Nothing is worse than having to resolve conflicts dozens of times before you are able to merge. A large rename to correct a spelling error can end up being the same experience has trying to merge a significant refactor — a multi-day effort. That’s not ideal.

Lucky for us, it’s possible to (help) prevent typos from ever getting merged in the first place. In Xcode, you can enable spelling from the Edit menu, Edit > Format > Spelling and Grammar > Check Spelling While Typing. Just like a typical word processor, Xcode will helpfully underline misspelled words and offer to apply corrections.

Even better, Xcode understands variable names and will correctly identify errors in camelCase, snake_case, and other common identifier formats. Xcode also understands programming language keywords and syntax, so func, for example, will not be identified as a spelling error. You can right-click to apply corrections. You can also add words to the dictionary via Right Click > Learn Spelling, which can be useful for domain-specific abbreviations or other non-dictionary terms that are not actual spelling errors.

The only caveat here is that everyone on your team must manually apply spelling corrections. However, perhaps this could be solved with a linter rule or Xcode extension.

Xcode spell checking

Xcode spell checking