Repository navigation
Add spell checking with tap corrections and optional dictionary actions - #454
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds misspelling underlines and tap-to-correct suggestions using public
UITextCheckerAPIs. SettingspellCheckingType = .yesenables checking independently of autocorrection; the private UIKit replacement-object workaround is removed.On iOS 16 and later, tapping a misspelled word opens a compact system menu containing corrections. Tapping another word, blank space, or scrolling dismisses it. Selecting text still offers corrections in the regular edit menu. Earlier iOS versions use the regular edit-menu fallback.
Ignore Spelling, Learn Spelling, and Unlearn Spelling are hidden by default. Applications can independently expose them in spelling and regular edit menus:
These settings control menu visibility; public dictionary APIs remain available. Changes invalidate existing spelling actions. Ignored words belong to one editor's document session: edits, undo, language changes, and checking toggles preserve them; assigning
text, callingsetState, or explicitly resetting starts a new session. Learned words use Apple's shared dictionary. When enabled, selecting a learned word offers Unlearn Spelling even after its underline disappears. Dictionary actions preserve text, selection, and text undo history.Checks are debounced, bounded, and scoped to visible text, including horizontally scrolled long lines. A dictionary language and delegate policy let applications exclude code or other ranges. Composing text is excluded and stale actions are rejected. Spelling pauses during Writing Tools sessions, and corrections use guarded system replacement with independent undo. Includes current main's Writing Tools improvements from #455, with exclusions and active-session edits preserved. Grammar integration and partial-word completion remain separate.
The example app includes a persistent Check Spelling setting, off by default.
Validation
git diff --checkpassed. Existing language-package lint and XCTest deployment-target warnings remain.Launch the UI test Host and tap Spelling for the default correction menu or Dictionary for explicitly enabled dictionary actions. Run
HostUITests/SpellCheckingTestsfor all three workflows.The iOS 14/15 fallback has not been runtime-tested here. Actual Apple Intelligence generation was not exercised.
Simulator proof
Unmodified screenshots from passing UI tests. Captures support visual review; behavioral assertions are in the tests.
Additional captures: undo, checking disabled, ignored word, and checking restored after Unlearn.
Example app setting from the earlier verified persistence check: