Swiftpack.co - rustle/AX as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by rustle.
rustle/AX 0.1.9
Helper things for HIServices Accessibility API
⭐️ 0
🕓 3 weeks ago
.package(url: "https://github.com/rustle/AX.git", from: "0.1.9")


Hopefully make it a little easier to use HIServices Accessibility APIs in Swift.

The goal of this package is to provide a nice overlay to existing API, not extend any functionality or solve any of thorny parts of using the HIServices Accessibility APIs.

Observer Example

Simplified example to show how to setup an AX Observer for NSAccessibility.Notifications from an application element.

You'll need to add/re-add ObserverExample to trusted apps for Accessibility in System Preferences any time you change the code.


Lots of good examples for integrating and using AX are available in AccessibilityElement.

Use of _ API

AX makes liberal use of ReferenceConvertible. More specifically _ prefixed (aka unstable) _ObjectiveCType, _forceBridgeFromObjectiveC, _conditionallyBridgeFromObjectiveC, and _unconditionallyBridgeFromObjectiveC. These give use the extremely nice to have ability to bridge not only individual elements

func foo(
    _ uiElement: AXUIElement,
) {
	let element = uiElement as UIElement

but collections

func foo(
    _ uiElements: CFArrayRef?,
) {
	guard let elements = uiElements as [UIElement] else { return }

Hopefully eventually a stable variant is provided and we can migrate to that. If push comes to shove this logic can be excised by adding helper functions that do functionally equivalent bridging.


AX is released under an Apache license. See the LICENSE file for more information.


Stars: 0
Last commit: 2 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.


Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics