From e12618bda41a13f32f5994fbf48e9803ce7f6c8a Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Wed, 23 Sep 2026 11:12:37 +0200 Subject: [PATCH] Initial work to replace a deprecated API --- Classes/Utilities.swift | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Classes/Utilities.swift b/Classes/Utilities.swift index c1db3c1..5358f54 100644 --- a/Classes/Utilities.swift +++ b/Classes/Utilities.swift @@ -17,12 +17,22 @@ func automationConsent(bundleIdentifier: String, promptIfNeeded: Bool) -> Privac var result: PrivacyConsentState = .denied if #available(macOS 10.14, *) { bundleIdentifier.withCString { (identifier) in - var addressDesc = AEAddressDesc() + let workspace = NSWorkspace.shared + +// if #available(macOS 12, *) { +// // Make sure the target is running, if not the consent alert will not be shown. +// if let url = workspace.urlsForApplications(withBundleIdentifier: bundleIdentifier).first { +// let configuration = NSWorkspace.OpenConfiguration() +// workspace.openApplication(at: url, configuration: configuration) {_,_ in +// } +// } +// } // Mare sure the target is running, if not the consent alert will not be shown. - NSWorkspace.shared.launchApplication(withBundleIdentifier: bundleIdentifier, options: [], - additionalEventParamDescriptor: nil, launchIdentifier: nil) + workspace.launchApplication(withBundleIdentifier: bundleIdentifier, options: [], + additionalEventParamDescriptor: nil, launchIdentifier: nil) + var addressDesc = AEAddressDesc() let createDescResult = AECreateDesc(typeApplicationBundleID, identifier, strlen(identifier), &addressDesc) if createDescResult == noErr { let appleScriptPermission = AEDeterminePermissionToAutomateTarget(&addressDesc, typeWildCard, typeWildCard, promptIfNeeded)