Skip to content

AXKit is a lightweight Swift library that generates accessibility identifiers for your UIKit views. It was written to simplify automated UI testing by providing consistent, structured identifiers for views.

License

Notifications You must be signed in to change notification settings

D-Integral/AXKit

Repository files navigation

AXKit

AXKit is a lightweight Swift library that generates accessibility identifiers for your UIKit views. It was written to simplify automated UI testing by providing consistent, structured identifiers for views.

Features

  • Automatically generates accessibility identifiers for any UIKit element.
  • Supports hierarchical identifiers including index, indexPath, and purpose.
  • Lightweight and simple to integrate.
  • Only active in DEBUG builds, ensuring no impact on production apps.

Usage

Step 1: Conform your class to Accessible

class MyViewController: UIViewController, Accessible {
    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var actionButton: UIButton!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setupAccessibilityIdentifiers()
    }
}

Step 2: Call setupAccessibilityIdentifiersForViewProperties

let info = AccessibilityInfo(indexPath: IndexPath(row: 0, section: 1),
                             purpose: "testing")
myViewController.setupAccessibilityIdentifiersForViewProperties(withAccessibilityInfo: info)

This will automatically assign accessibility identifiers to all UIView properties in your class based on their property name and optional metadata:

<MyViewController>.<propertyName>[.s<Section>-r<Row>][.<Index>][.<Purpose>]

Example:

For a button property named actionButton in section 1, row 0 with purpose "testing", the resulting identifier will be:

MyViewController.actionButton.s1-r0.testing

Notes

Identifiers are only generated in DEBUG builds.

The library uses reflection (Mirror) to automatically find all UIView properties in your class.

Useful for UI testing, especially with XCTest.

License

AXKit is available under the MIT license. See the LICENSE file for more info.

Author

Dmytro Skorokhod

About

AXKit is a lightweight Swift library that generates accessibility identifiers for your UIKit views. It was written to simplify automated UI testing by providing consistent, structured identifiers for views.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published