Fix FindMy folder permission not surviving a relaunch - #51
Open
gheydon wants to merge 1 commit into
Open
Conversation
Picking the FindMy folder granted access for one sync and then lost it, so the only thing that kept working was Full Disk Access - a far broader grant than the app needs, since it reads nothing but the FindMy data. Two things went wrong. The bookmark was never stored: @AppStorage was declared as a local variable inside the importer callback, where the assigned value becomes the wrapper's default rather than a write to UserDefaults, and the variable was then unused. And nothing ever resolved a bookmark, so no launch path could have restored access even had one been saved. The visible effect was that access appeared to work. The picker opened the security scope, the sync that ran immediately afterwards succeeded, and the deferred stopAccessingSecurityScopedResource then closed it - leaving every later timer-driven sync to fail against a folder the app could no longer read. Move the handling into DataAccess, which writes a security-scoped bookmark, resolves it on the next launch, refreshes it when stale, and holds the scope for the lifetime of the process. The importer callback, previously duplicated between the two availability branches, now calls one handler. 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.
Related: #11 — though see the note at the end, this is probably a different bug from the one reported there.
The problem
Picking the FindMy folder grants access for exactly one sync, then loses it. The practical result is that Full Disk Access ends up being the only thing that works — a far broader grant than the app needs, since it reads nothing but the FindMy data.
Two causes
The bookmark was never stored. In
AppView.swift:@AppStoragedeclared as a local variable inside the importer callback does not write toUserDefaults— the assigned value becomes the property wrapper's default. The variable is then unused. Nothing is persisted.Nothing ever resolved a bookmark. There is no
URL(resolvingBookmarkData:)anywhere in the codebase, so even had one been saved, no launch path could restore access.Why it looks like it works
The picker opens the security scope, the sync that runs immediately afterwards succeeds, and then
defer { url.stopAccessingSecurityScopedResource() }closes it when the callback returns. Every later timer-driven sync then fails against a folder the app can no longer read. Access appears to work and quietly stops.The fix
A small
DataAccesstype that:.withSecurityScope, rather than.minimalBookmark, which does not preserve scope)deferThe importer callback — previously duplicated verbatim across the two availability branches — now calls a single
onDirectoryPickedhandler.Testing
What I could not verify: that this removes the need for Full Disk Access on the real FindMy directories. My test machine runs macOS 26, where
~/Library/com.apple.icloud.searchpartyddoes not exist, and the test process inherited Full Disk Access anyway — so a successful read there would prove nothing about TCC. What is definitely fixed is the persistence bug, which was unambiguously broken. Whether a bookmark alone suffices for those directories deserves a second opinion from someone able to test it.On #11
I am referencing that issue as related context rather than claiming to close it. The symptom reported there is that the permission dialog never appears and Full Disk Access does not help, which is a different failure from the one fixed here. What this PR does address is the reason people end up on Full Disk Access in the first place — the narrower folder grant not surviving.
🤖 Generated with Claude Code