How can I refresh the macOS dictionary?

Consider the following workflow:

  1. Open TextEdit.
  2. Type a word that's not in the dictionary.
  3. Right-click on that word and select 'Learn Spelling'.
  4. Observe the squiggly underline disappears, as the word is now recognised.
  5. Observe the word is added to the ~/Spelling/LocalDictionary file.
  6. Quit TextEdit.
  7. Remove the word from the ~/Spelling/LocalDictionary file.
  8. Reopen TextEdit.
  9. Type the same word again.
  10. Observe it is still recognised (not squiggly-underlined), despite no longer being in the local dictionary.

It seems the problem here is that there is some sort of cache maintained by macOS that is not refreshed. If I right-click on the word in TextEdit to remove it from the local dictionary instead of editing the file, it is indeed no longer recognised; i.e., this appears to update the cache.

Is there any way I can manually refresh the cache of local dictionary words?


I figured this out myself in the end. One needs to relaunch the com.apple.applespell service (from the command line).

launchctl stop com.apple.applespell
launchctl start com.apple.applespell