Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize Core Data containers #1017

Merged
merged 10 commits into from
Dec 15, 2024
Merged

Conversation

keeshux
Copy link
Member

@keeshux keeshux commented Dec 15, 2024

Before anything, remove any code related to App Group containers from tvOS target because they are not available. Include the beta receipt override, it's broken for that reason.

In short:

  • Store all Core Data containers locally. Do not use the App Group for Core Data for consistency across platforms.
  • Store logs in the App Group on iOS/macOS, but locally on tvOS (see urlForCaches).

Then, rather than one container per model, merge models into:

  • Local: Providers
  • Remote: Profiles + Preferences (now in the same CloudKit container)

Reuse the remote model for backups too.

This change is safe because:

  • Local profiles are stored via Network Extension in the keychain, not Core Data
  • Remote profiles are re-imported via CloudKit sync
  • Providers are re-downloaded on first use
  • Preferences are lost, but they are "cheap" data
  • Profile backups are lost, but they were hidden anyway

@keeshux keeshux self-assigned this Dec 15, 2024
@keeshux keeshux added the refactoring Improves software architecture label Dec 15, 2024
@keeshux keeshux added this to the 3.0.0 / 7. Release milestone Dec 15, 2024
@keeshux keeshux merged commit ffb8829 into master Dec 15, 2024
1 check passed
@keeshux keeshux deleted the refactoring/core-data-containers branch December 15, 2024 19:20
keeshux added a commit that referenced this pull request Dec 20, 2024
The remote container is shared by ProfileManager and
PreferencesManager, but it must be the same for CloudKit sync
to work properly.

Externalize the logic of onEligibleFeatures() so that the
AppContext singleton can update the managers (and their
repositories) with the new remote store.

Now that the remote profile repository is reloaded every time that
eligible features change, the .removeDuplicates() may also be
restored. Just add a .dropFirst() to skip the initially empty
value of eligible features. Even when features are eventually empty,
a value is always emitted after IAPManager.reloadReceipt()

Lastly, enable Core Data lightweight migration.

Regressions from #1017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Improves software architecture
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant