Fix 3.0 migration to read from NSUserDefaults instead of Core Data#5
Merged
Conversation
LegacyDataMigrator was scanning for a Core Data SQLite store that pre-3.0 installs never had — the v1/v2 app persisted user content in NSUserDefaults under "categories" ([String]) and "dittos" ([String: [String]]). On upgrade the migration silently no-op'd and DittoStore filled the new SwiftData container with presets, which is why users saw their dittos disappear. - Rewrite migrator to read the legacy NSUserDefaults keys from both the App Group suite and UserDefaults.standard, merging by title when both are populated. - Reuse any existing Profile (e.g. one already filled with presets by a broken 3.0 launch) and merge legacy categories/dittos into it by title/text, so affected users recover their data without duplicates on the next launch. - Do NOT delete the legacy keys from NSUserDefaults; the source data stays intact so users can roll back or re-run if needed. - Switch the completion flag key so installs that were marked complete by the broken Core Data migrator will run the new NSUserDefaults migration once. - Update tests to cover detection, order preservation, the no-delete invariant, and the standard-defaults fallback path.
- LegacyDataMigratorTests: replace the 5-element tuple with a private DefaultsSnapshot struct so SwiftLint's large_tuple rule passes. - LegacyDataMigrator: drop the indented `/// - ` bullets in the doc comment so the consecutiveSpaces rule no longer flags them. - ScreenshotTests: mark the XCTestCase subclass @mainactor so calls to the @MainActor-isolated setupSnapshot / snapshot helpers compile under stricter actor isolation checking (pre-existing on master). - SnapshotHelper: collapse the double space after `?` on the landscape ternary so consecutiveSpaces no longer fails the SwiftFormat job (pre-existing on master).
Swift Testing creates a fresh struct instance per @test method, so the prior static helpers couldn't be reached from instance methods without a Self. prefix and the compiler rejected the bare references. Demote the helpers and constants to instance members so the @test methods can call them directly.
The Tests and UI Tests step timeouts (10 min) tripped on this branch after the @mainactor fix unblocked the build. Worse, the trailing `| tail -30` buffered xcodebuild's output until the pipeline finished, so when the step timed out there was no useful progress to diagnose. - Bump Run unit tests step timeout 10 → 15 min and the job to 25 min. - Bump Run UI tests step timeout 10 → 15 min and the job to 30 min. - Drop the trailing tail so xcodebuild output streams as it runs, and add a Show-test-errors step that prints the last 200 lines on failure so a hang or slow test is visible in the action log.
Tests still timed out at the 15-min step budget. Adding xcodebuild's per-test timeout (60s default, 180s max) so a single hung test gets killed and reported by xcresult instead of consuming the whole step budget, and so we can identify which test stalls.
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.
LegacyDataMigrator was scanning for a Core Data SQLite store that
pre-3.0 installs never had — the v1/v2 app persisted user content
in NSUserDefaults under "categories" ([String]) and "dittos"
([String: [String]]). On upgrade the migration silently no-op'd
and DittoStore filled the new SwiftData container with presets,
which is why users saw their dittos disappear.
both the App Group suite and UserDefaults.standard, merging by
title when both are populated.
by a broken 3.0 launch) and merge legacy categories/dittos into
it by title/text, so affected users recover their data without
duplicates on the next launch.
data stays intact so users can roll back or re-run if needed.
complete by the broken Core Data migrator will run the new
NSUserDefaults migration once.
no-delete invariant, and the standard-defaults fallback path.