Quickstart
This guide will help you to get started with the Abra SDK package for iOS.
Setup
The Swift Package is published at: GitHub
-
Open Xcode and select
File > Add Package Dependencies...
from the menu bar. -
Paste the URL of the package in the search field in the top-right corner:
https://github.com/abra-nl/abra-sdk-ios-package
-
Press
Add Package
in the bottom-right corner.tipYou can also set
Dependency Rule
toExact Version
, for example1.1.0
. -
Select your UI testing target in the
Add to Target
column. -
Press
Add Package
in the bottom-right corner.
Check the release notes for available version.
Usage
After adding the package, you are ready to use it in your test target.
-
Import the SDK:
import AbraSDK
-
Configure the SDK:
let config = AbraConfig(
license: "<YOUR-SDK-LICENSE>",
identifier: "<YOUR-APP-IDENTIFIER>"
)
let abra = try await Abra(config: config) -
Configure the rules:
let abraRules = abra.abraRuleBuilder.all().build()
let appleRules = abra.appleRuleBuilder.all().build() -
Perform an audit:
let results = try abra.audit(rules: rules)
Example
Also check the Abra API for iOS to learn how to upload results to the Abra Dashboard.
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

