Skip to main content

Quickstart

This guide will help you to get started with the Abra SDK package for iOS.

Setup

The Swift Package is published at: GitHub

  1. Open Xcode and select File > Add Package Dependencies... from the menu bar.

    Screenshot highlighting the 'Add Package Dependencies' item in the menubarScreenshot highlighting the 'Add Package Dependencies' item in the menubar
  2. Paste the URL of the package in the search field in the top-right corner:

    https://github.com/abra-nl/abra-sdk-ios-package
  3. Press Add Package in the bottom-right corner.

    Screenshot highlighting the search field and 'Add package' buttonScreenshot highlighting the search field and 'Add package' button
    tip

    You can also set Dependency Rule to Exact Version, for example 1.1.0.

  4. Select your UI testing target in the Add to Target column.

  5. Press Add Package in the bottom-right corner.

    Screenshot highlighting the target selector and 'Add package' buttonScreenshot highlighting the target selector and 'Add package' button
tip

Check the release notes for available version.

Usage

After adding the package, you are ready to use it in your test target.

  1. Import the SDK:

    import AbraSDK
  2. Configure the SDK:

    let config = AbraConfig(
    license: "<YOUR-SDK-LICENSE>",
    identifier: "<YOUR-APP-IDENTIFIER>"
    )
    let abra = try await Abra(config: config)
  3. Configure the rules:

    let abraRules = abra.abraRuleBuilder.all().build()
    let appleRules = abra.appleRuleBuilder.all().build()
  4. Perform an audit:

    let results = try abra.audit(rules: rules)

Example

tip

Also check the Abra API for iOS to learn how to upload results to the Abra Dashboard.

AbraTestCase.swift
import XCTest
import AbraSDK

class AbraTestCase: XCTestCase {

private let LICENSE = "XXXXXXXXXX"
private let IDENTIFIER = "com.apple.Preferences"

internal var abra: Abra!
internal var rules: [Rule]!

/// Setup the Abra SDK
override func setUp() async throws {
try await super.setUp()

let config = AbraConfig(
license: LICENSE,
identifier: IDENTIFIER
)
self.abra = try await Abra(config: config)
self.rules = abra.abraRuleBuilder.all().build() +
abra.appleRuleBuilder.all().build()
}

/// Audit accessibility of app using Apple rules
func testAccessibility() throws {
let app = XCUIApplication(bundleIdentifier: IDENTIFIER)
app.activate()

let results = try abra.audit(rules: rules)

try results.forEach { result in
if result.metadata.type == .error {
// Use helper method to get snapshots and screenshots as attachments
let attachments = try result.getAttachments()
attachments.forEach { attachment in
add(attachment)
}
// Log failure using result description
XCTFail(result.metadata.message)
}
}
}
}

Results

Screenshot of Xcode Report Navigator, which shows failures together with screenshot, snapshot and element attachmentsScreenshot of Xcode Report Navigator, which shows failures together with screenshot, snapshot and element attachments