From 4612e37721d968fe880abb155ec92814a6a82922 Mon Sep 17 00:00:00 2001 From: "louis.pontoise" Date: Fri, 24 Jan 2020 10:05:13 +0900 Subject: [PATCH] fix: only test permissions on the correct os versions --- alt-tab-macos/logic/SystemPermissions.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/alt-tab-macos/logic/SystemPermissions.swift b/alt-tab-macos/logic/SystemPermissions.swift index 5e9c715f..1bd48604 100644 --- a/alt-tab-macos/logic/SystemPermissions.swift +++ b/alt-tab-macos/logic/SystemPermissions.swift @@ -1,10 +1,10 @@ import Foundation import Cocoa -// macOS has some privacy restrictions. The user needs to grant certain permissions, app by app, in System Preferences > Security & Privacy > Privacy +// macOS has some privacy restrictions. The user needs to grant certain permissions, app by app, in System Preferences > Security & Privacy class SystemPermissions { - // macOS 10.9+ static func ensureAccessibilityCheckboxIsChecked() { + guard #available(OSX 10.9, *) else { return } if !AXIsProcessTrustedWithOptions(["AXTrustedCheckOptionPrompt": true] as CFDictionary) { debugPrint("Before using this app, you need to give permission in System Preferences > Security & Privacy > Privacy > Accessibility.", "Please authorize and re-launch.", @@ -14,8 +14,9 @@ class SystemPermissions { } } - // macOS 10.15+ static func ensureScreenRecordingCheckboxIsChecked() { + guard #available(OSX 10.15, *) else { return } + // there is no API to check this permission; we try to get a screenshot to check indirectly let firstWindow = CGWindow.windows(.optionOnScreenOnly)[0] if let cgId = firstWindow.id(), cgId.screenshot() == nil { debugPrint("Before using this app, you need to give permission in System Preferences > Security & Privacy > Privacy > Screen Recording.",