Storage Location Manager
Manages user-selected storage folder with security-scoped bookmarks.
Purpose
Allows users to choose where data is stored:
- Default:
~/Documents/Minuta/ - Custom: Any user-accessible folder
- Persists selection across app launches
Protocol
@MainActor
protocol StorageLocationManagerProtocol {
var storageURL: URL? { get }
var hasValidStorageLocation: Bool { get }
func selectStorageLocation() async -> URL?
func resetToDefault()
} Security-Scoped Bookmarks
Required for sandboxed apps to access user-selected folders:
- User picks folder via system picker
- App creates security-scoped bookmark
- Bookmark stored in UserDefaults
- On launch, bookmark resolved to URL
startAccessingSecurityScopedResource()called
UI Integration
- 405-settings-sheet shows current path
- “Choose Folder” button opens picker
- “Reset to Default” restores default location
First Launch
If no folder selected:
- Shows 406-storage-setup view
- User must pick folder before using app
Related
- 403-app-state - Uses storage location
- 301-file-storage - File operations
- 305-storage-location - Detailed documentation