diff --git a/Package.swift b/Package.swift index 49f678e..374b35b 100644 --- a/Package.swift +++ b/Package.swift @@ -22,7 +22,10 @@ let package = Package( targets: [ .target( name: "AX", - dependencies: []), + dependencies: []/*, + swiftSettings: [ + .enableExperimentalFeature("StrictConcurrency") + ]*/), .executableTarget( name: "ObserverExample", dependencies: ["AX"]), diff --git a/Sources/AX/AX.swift b/Sources/AX/AX.swift index d806501..2d30179 100644 --- a/Sources/AX/AX.swift +++ b/Sources/AX/AX.swift @@ -24,12 +24,16 @@ public func isTrusted() -> Bool { /// /// See also `public func AXIsProcessTrustedWithOptions(_ options: CFDictionary?) -> Bool` @available(macOS 10.9, *) +@Sendable public func isTrusted(promptIfNeeded: Bool) -> Bool { AXIsProcessTrustedWithOptions(optionsDictionary(promptIfNeeded: promptIfNeeded)) } +private struct AXKey: Sendable { + static let trustedCheckOptionPrompt = kAXTrustedCheckOptionPrompt.takeUnretainedValue() +} private func optionsDictionary(promptIfNeeded: Bool) -> CFDictionary { guard promptIfNeeded else { return [CFString:CFTypeRef]() as CFDictionary } - return [kAXTrustedCheckOptionPrompt.takeUnretainedValue():kCFBooleanTrue] as CFDictionary + return [AXKey.trustedCheckOptionPrompt:kCFBooleanTrue] as CFDictionary } diff --git a/Sources/AX/AXError.swift b/Sources/AX/AXError.swift index 402f67c..d6b8bb3 100644 --- a/Sources/AX/AXError.swift +++ b/Sources/AX/AXError.swift @@ -10,7 +10,7 @@ import ApplicationServices.HIServices // but we want to drop the `success` case @available(macOS 10.2, *) -public enum AXError: Error { +public enum AXError: Error, Sendable { /// The action is not supported by the UIElement. case actionUnsupported /// The accessibility API is disabled. diff --git a/Sources/AX/AXObserver.swift b/Sources/AX/AXObserver.swift index 739b74b..90f612f 100644 --- a/Sources/AX/AXObserver.swift +++ b/Sources/AX/AXObserver.swift @@ -9,7 +9,7 @@ import Foundation import AppKit @available(macOS 10.2, *) -public struct Observer: CustomStringConvertible, CustomDebugStringConvertible { +public struct Observer: @unchecked Sendable, CustomStringConvertible, CustomDebugStringConvertible { // MARK: Init diff --git a/Sources/AX/AXTextMarker.swift b/Sources/AX/AXTextMarker.swift index 1ab53cf..a7fbca3 100644 --- a/Sources/AX/AXTextMarker.swift +++ b/Sources/AX/AXTextMarker.swift @@ -8,7 +8,7 @@ import ApplicationServices import Cocoa @available(macOS 11, *) -public struct TextMarker: CustomStringConvertible, CustomDebugStringConvertible { +public struct TextMarker: @unchecked Sendable, CustomStringConvertible, CustomDebugStringConvertible { // MARK: Init @@ -51,7 +51,7 @@ public struct TextMarker: CustomStringConvertible, CustomDebugStringConvertible } @available(macOS 11, *) -public struct TextMarkerRange: CustomStringConvertible, CustomDebugStringConvertible { +public struct TextMarkerRange: @unchecked Sendable, CustomStringConvertible, CustomDebugStringConvertible { // MARK: Init diff --git a/Sources/AX/AXUIElement.swift b/Sources/AX/AXUIElement.swift index af4e4e4..315357e 100644 --- a/Sources/AX/AXUIElement.swift +++ b/Sources/AX/AXUIElement.swift @@ -5,11 +5,10 @@ // import AppKit -import ApplicationServices -import Cocoa +@preconcurrency import ApplicationServices @available(macOS 10.0, *) -public struct UIElement: CustomStringConvertible, CustomDebugStringConvertible { +public struct UIElement: Sendable, CustomStringConvertible, CustomDebugStringConvertible { // MARK: Init diff --git a/Sources/AX/AXValue.swift b/Sources/AX/AXValue.swift index 1d20a6e..7e1645e 100644 --- a/Sources/AX/AXValue.swift +++ b/Sources/AX/AXValue.swift @@ -8,7 +8,7 @@ import ApplicationServices import Cocoa @available(macOS 10.11, *) -public enum Value: Equatable { +public enum Value: Equatable, Sendable { case point(CGPoint) case size(CGSize) case rect(CGRect)