Add setting to sync clipboard history across Macs via iCloud - #1
Open
chamika wants to merge 1 commit into
Open
Conversation
Adds a Data settings toggle that keeps clipboard history in sync on every Mac signed in to the same Apple Account, backed by a CloudKit private database. CloudSyncManager owns the preference and reports whether the running store is actually CloudKit-backed. SwiftData cannot move a store between local and CloudKit at runtime, so the preference is read once while building the ModelContainer and Settings offers a relaunch when it changes. If the CloudKit store fails to open, the app falls back to the local store instead of trapping, and Settings explains why sync is off. Removes the #Unique constraint on contentHash: CloudKit-backed stores reject unique constraints, and the model has to stay CloudKit-compatible regardless of the toggle since both modes share one schema. ClipboardMonitor collapses duplicate hashes instead, which also covers the same content being copied on two Macs. Sync is gated off by default via CloudSyncManager.isSupported. Apple does not grant the iCloud capability to free personal development teams, so the entitlements file ships unreferenced and the toggle is disabled until the app is signed by a paid team. Re-enabling steps are documented on the flag. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Summary
Adds a Data → iCloud settings toggle that keeps clipboard history in sync on every Mac signed in to the same Apple Account, backed by a CloudKit private database.
CloudSyncManagerowns the preference, checksCKAccountStatus, and tracks whether the running store is actually CloudKit-backed.ModelContainer. Settings surfaces this and offers a Relaunch button rather than pretending the change is live.DataSettingsViewmoved out ofSettingsView.swiftinto its own file, matching the other settings views.Sync is gated off in this build
Apple does not grant the iCloud capability to free personal development teams — Xcode refuses to issue a provisioning profile for it at all. So
CloudSyncManager.isSupportedisfalse, the entitlements file ships unreferenced, and the toggle is disabled with an explanation. The re-enabling steps (flip the flag, restoreCODE_SIGN_ENTITLEMENTS+APS_ENVIRONMENT, add the capability in Xcode) are documented on the flag itself.project.pbxprojis unchanged by this PR.Note on the schema change
#Unique<ClipboardItem>([\.contentHash])is removed. CloudKit-backed stores reject unique constraints, and the model has to stay CloudKit-compatible regardless of the toggle since both modes share one schema — so this had to be unconditional.ClipboardMonitornow collapses duplicate hashes on lookup (keeping the newest, preserving a pin if any duplicate had one), which is equivalent for local-only use and additionally covers the same content being copied on two Macs.Removing a uniqueness constraint is a lightweight Core Data migration, so existing local histories should open fine — but that is the one thing not verified against a real populated store.
Test plan
VoltPasteTestspassapp-sandboxandfiles.user-selected.read-onlyintact, no iCloud keys, no stray.entitlementscopied into the bundle🤖 Generated with Claude Code