Skip to content

Fix search, case and loader bugs before 3.0.0 - #8

Merged
mabidakun merged 14 commits into
masterfrom
fix/pre-release-bugs
Oct 24, 2026
Merged

mabidakun merged 14 commits into
masterfrom
fix/pre-release-bugs

Conversation

@mabidakun

Copy link
Copy Markdown
Owner

What does this PR do?

  • Problem: 3.0.0 is the last version that can go to CocoaPods, because Trunk becomes read-only on 2026-12-02. A bug that ships in it cannot be fixed for CocoaPods users. A bug hunt with probe tests and two cold reviews found the bugs below.
  • This PR: fixes them, each in its own commit with a test that failed before the fix.
    • Crash: a string of a few thousand characters crashed the app (stack overflow) when the trie was searched, freed or had the string removed on a background thread. Search, removal and freeing now loop instead of recursing (51de618, a1f5b53). Freeing leaves alone any node that something else still holds (3e737ec).
    • Case preservation: with preserveCase: true, strings added after init, or with surrounding whitespace, came back lowercase (616283b).
    • Whitespace: a whitespace-only string was stored as an empty word (4360dee). A trailing space in a prefix was dropped, so "new " matched "newark" (fa44a2d). Prefixes and stored strings now trim the same characters (77d201a).
    • Unicode: matching now uses case folding, so "Straße" matches "strass" and "İstanbul" matches "ist" (b4a087c). Results use the stored characters, not the caller's form of the prefix (6054582).
    • StringLoader: \r\n is one line break, and empty and whitespace-only lines are skipped (fc58300, 4958ae7).
    • Docs and tidy-up: the README has a "Matching Rules" section (0293cfb), the doc comments say that case variants collapse to the last one added (1b71d87), and helpers that only tests used are removed (00d1537, a1f5b53).
  • Callers can see some behaviour changes. A prefix with a trailing space now matches fewer strings, Unicode case variants now match each other, and StringLoader no longer returns empty lines or trims the first and last lines. Results without preserveCase are still the lowercased original text, for example "straße".

Test Evidence

Run locally on 3e737ec with Xcode 27.1:

Check Command Result
Unit tests (debug) swift test 108 passed, 0 failed
Unit tests (release) swift test -c release -Xswiftc -enable-testing 108 passed, 0 failed
iOS build xcodebuild -scheme StringSearchKit -destination 'generic/platform=iOS' build succeeded
tvOS build xcodebuild -scheme StringSearchKit -destination 'generic/platform=tvOS' build succeeded
Podspec lint pod lib lint --platforms=macos,ios passed

The CI run adds the full pod lib lint with tvOS.

Every fix has a test that failed (or crashed with signal 10) before the fix. Two cold reviews mutation-checked the commits up to 77d201a: each mutation made at least one test fail.

How should this be manually tested?

  1. Add the package from this branch to a test app.
  2. On a background queue, create StringDictionary(withStrings: [String(repeating: "a", count: 20_000)]), call strings(withPrefix: "a"), then let it go out of scope. Expect no crash.
  3. Create StringDictionary(withStrings: ["Straße", "new york", "newark"], preserveCase: true). Expect strings(withPrefix: "STRASS") to be ["Straße"] and strings(withPrefix: "new ") to be ["new york"].

Background

  • Merge order: this PR, then the PR that adds AGENTS.md and CLAUDE.md (stacked on this branch), then a small follow-up for README and podspec points that already exist on master.
  • After these merge: tag 3.0.0, create the GitHub release, and run pod trunk push by 2026-10-31.

@mabidakun mabidakun added the bug label Oct 24, 2026
@mabidakun
mabidakun merged commit 1cb4ac7 into master Oct 24, 2026
1 check passed
@mabidakun
mabidakun deleted the fix/pre-release-bugs branch October 24, 2026 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant