feat: guided permissions onboarding for Accessibility and Screen Recording - #84
Open
iOSDevSK wants to merge 1 commit into
Open
feat: guided permissions onboarding for Accessibility and Screen Recording#84iOSDevSK wants to merge 1 commit into
iOSDevSK wants to merge 1 commit into
Conversation
…rding Replaces the silent accessibility polling with a welcome window that walks the user through both required permissions: - Fires the native system prompts, which auto-add the app to the Privacy & Security lists, and deep-links to the exact System Settings pane - no manual hunting - Polls TCC state and shows live checkmarks; shortcuts activate the moment Accessibility lands, no restart needed - Probes ScreenCaptureKit directly to detect a Screen Recording grant (CGPreflightScreenCaptureAccess caches its answer for the process lifetime) and restarts the app automatically when required - Stale entries left by a previous build (whose code signature no longer matches) are reset via tccutil, so the fresh prompt works instead of silently failing Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Someone is attempting to deploy a commit to the knox projects Team on Vercel. A member of the Team first needs to authorize it. |
| } | ||
| } | ||
|
|
||
| private func runTCCReset(service: String, bundleID: String) { |
Contributor
There was a problem hiding this comment.
tccutil reset is run on the main actor here, and waitUntilExit() can block the UI (and potentially the onboarding window) longer than needed.
Suggested change
| private func runTCCReset(service: String, bundleID: String) { | |
| private func runTCCReset(service: String, bundleID: String) { | |
| Task.detached(priority: .utility) { | |
| let process = Process() | |
| process.executableURL = URL(fileURLWithPath: "/usr/bin/tccutil") | |
| process.arguments = ["reset", service, bundleID] | |
| do { | |
| try process.run() | |
| process.waitUntilExit() | |
| } catch { } | |
| } | |
| } |
| NSApp.activate(ignoringOtherApps: true) | ||
| window?.makeKeyAndOrderFront(nil) | ||
|
|
||
| startPolling() |
Contributor
There was a problem hiding this comment.
Minor UX: if Accessibility is already granted when this window opens, shortcuts won’t get registered until the first poll tick (up to 1s). You can register immediately before starting the timer.
Suggested change
| startPolling() | |
| if accessibilityGranted && !ShortcutService.shared.isRegistered { | |
| ShortcutService.shared.registerAll() | |
| } | |
| startPolling() |
| } | ||
| } | ||
|
|
||
| static func restartApp() { |
Contributor
There was a problem hiding this comment.
Small consistency thing: elsewhere you use executableURL, but restartApp() uses launchPath (deprecated). Suggest switching to executableURL.
Suggested change
| static func restartApp() { | |
| static func restartApp() { | |
| let task = Process() | |
| task.executableURL = URL(fileURLWithPath: "/bin/sh") | |
| task.arguments = ["-c", "sleep 0.5; open \"\(Bundle.main.bundlePath)\""] | |
| try? task.run() | |
| NSApp.terminate(nil) | |
| } |
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.
What
Replaces the silent accessibility polling on first launch with a welcome window that walks the user through both required permissions — no manual hunting through System Settings.
How it works
AXIsProcessTrustedWithOptions/CGRequestScreenCaptureAccess), which auto-add the app to the Privacy & Security lists, and deep-links to the exact Settings pane (x-apple.systempreferences:...Privacy_Accessibility/Privacy_ScreenCapture)CGPreflightScreenCaptureAccesscaches its answer for the process lifetime, so a Screen Recording grant made while the app runs never turns true — the window probes ScreenCaptureKit directly to detect the grant and restarts the app automatically when requiredtccutil resetso the fresh prompt + auto-add worksScope
Single file (
BetterShotDelegate.swift) +CHANGELOG.mdunder Unreleased. No version bump.Testing
make releasebuilds cleantccutil reset): both prompts fire, Settings opens on the right pane, checkmarks appear within seconds of flipping the toggles, shortcuts work without restart after Accessibility, and the app auto-restarts after Screen RecordingNote: on the newest Xcode toolchains
mainitself doesn't compile — see #80 for minimal Swift 6 concurrency fixes. This PR is independent of it.🤖 Generated with Claude Code