Add Security-Scoped Bookmarks for local file access#3
Open
fxd0h wants to merge 1 commit intob451c:mainfrom
Open
Add Security-Scoped Bookmarks for local file access#3fxd0h wants to merge 1 commit intob451c:mainfrom
fxd0h wants to merge 1 commit intob451c:mainfrom
Conversation
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
QuickMD can't display local images (e.g.
) in sandboxed builds because the app only gets read access to the file the user opens, not to sibling files in the same directory.This PR adds a
SandboxAccessManagerthat handles Security-Scoped Bookmarks:NSOpenPanelto grant folder accessUserDefaultsso subsequent launches restore access silentlyChanges
SandboxAccessManager.swift@MainActorsingleton managing bookmark creation, persistence, and restorationImageBlockView.swiftproject.pbxprojSandboxAccessManager.swiftQuickMD.entitlementscom.apple.security.files.bookmarks.app-scopeentitlementCHANGELOG.mdDesign Decisions
NSOpenPanelonly appears when an image actually fails to load, not on every file open. This avoids unnecessary prompts for markdown files without local images.@MainActorisolation:SandboxAccessManageris marked@MainActorfor thread safety sinceImageBlockViewcalls it from async contexts.Testing
Tested with a signed build (sandbox enforced):
Fully App Store compliant — no temporary sandbox exceptions needed.