A Swift Package Manager (SPM) command plugin that scans your iOS Swift codebase for accessibility issues using BrowserStack’s Accessibility DevTools rule engine.
AccessibilityDevTools enables static accessibility linting directly inside Xcode via SwiftPM, helping teams catch WCAG violations early—before UI tests, QA, or production.
- 🔍 Automatic static accessibility linting for SwiftUI
- 🛠 10+ WCAG-aligned rules from the Spectra rule engine
- 🛠 Inline errors inside Xcode with remediation guidance
- ⚡ Runs during build using the SPM command plugin
- Projects created with XCode
- Projects created with Swift package manager
-
Log in to your BrowserStack account or sign up if you don’t have an account.
-
Obtain your Username and Access Key from the Account & Profile section section on the dashboard.

-
Set the following environment variables using the Username and Access Key you obtained in step 2.
BROWSERSTACK_USERNAMEBROWSERSTACK_ACCESS_KEY
-
To set these variables, add the appropriate export commands to your shell configuration file:
- Zsh: Add the following lines to your
~/.zshrcfile:
export BROWSERSTACK_USERNAME=<your-username> export BROWSERSTACK_ACCESS_KEY=<your-access-key>
- Bash: Add the following lines to your
~/.bashrcor~/.bash_profilefile:
export BROWSERSTACK_USERNAME=<your-username> export BROWSERSTACK_ACCESS_KEY=<your-access-key>
- Fish Shell: Add the following lines to your ~/.config/fish/config.fish file:
set -x BROWSERSTACK_USERNAME <your-username> set -x BROWSERSTACK_ACCESS_KEY <your-access-key>
- Zsh: Add the following lines to your
Note: XCode projects don’t have a
Package.swiftfile. However, the script will manage this for you. If you prefer not to do this or face any issues, you can use our CLI for linting instead.
Run the following command at the root of your repository
Zsh
curl -L -o browserstack-a11y-scan-spm.sh "https://raw.githubusercontent.com/browserstack/AccessibilityDevTools/refs/heads/main/scripts/zsh/spm.sh" && chmod 0775 browserstack-a11y-scan-spm.shBash
curl -L -o browserstack-a11y-scan-spm.sh "https://raw.githubusercontent.com/browserstack/AccessibilityDevTools/refs/heads/main/scripts/bash/spm.sh" && chmod 0775 browserstack-a11y-scan-spm.shFish
curl -L -o browserstack-a11y-scan-spm.sh "https://raw.githubusercontent.com/browserstack/AccessibilityDevTools/refs/heads/main/scripts/fish/spm.sh" && chmod 0775 browserstack-a11y-scan-spm.sh- In Xcode, select first item (project root) in the left folder tree and go to Build Settings tab
- Search for
sandbox> SetUser script sandboxingto “NO”
Repeat these steps for each target in your project
- Select a target from the targets left sidebar and go to Build Phases tab
- Click + to create a new build phase. Name the newly created build phase to a name such as BrowserStack Accessibility Linter.

- Drag this newly created build phase above Compile Sources step
- Delete any existing code in the newly created build step and add the following code
- Add this script:
./browserstack-a11y-scan-spm.sh --include **/*.swift --non-strict
Xcode will now automatically run the accessibility scan during builds.
Register plugin as dependency in your Package.swift file
Edit the Package.swift to include following code. Specifically, add these two things:
- Add
AccessibilityDevToolsas a package under dependencies - Add
a11y-scanas a plugin under each target that you have in your project
let package = Package(
name: "MyProject",
// platforms, products, etc.
dependencies: [
// other dependencies
.package(
url: "https://github.com/browserstack/AccessibilityDevTools.git",
branch: "main"
),
],
targets: [
.executableTarget(
name: "MyApp",
dependencies: [],
plugins: [
.plugin(
name: "a11y-scan",
package: "AccessibilityDevTools"
)
]
)
]
)Run the following command at the root of your repository
Zsh
curl -L -o browserstack-a11y-scan-spm.sh "https://raw.githubusercontent.com/browserstack/AccessibilityDevTools/refs/heads/main/scripts/zsh/spm.sh" && chmod 0775 browserstack-a11y-scan-spm.shBash
curl -L -o browserstack-a11y-scan-spm.sh "https://raw.githubusercontent.com/browserstack/AccessibilityDevTools/refs/heads/main/scripts/bash/spm.sh" && chmod 0775 browserstack-a11y-scan-spm.shFish
curl -L -o browserstack-a11y-scan-spm.sh "https://raw.githubusercontent.com/browserstack/AccessibilityDevTools/refs/heads/main/scripts/fish/spm.sh" && chmod 0775 browserstack-a11y-scan-spm.sh- In Xcode, select first item (project root) in the left folder tree and go to Build Settings tab
- Search for
sandbox> SetUser script sandboxingto “NO”
Repeat these steps for each target in your project
- Select a target from the targets left sidebar and go to Build Phases tab
- Click + to create a new build phase. Name the newly created build phase to a name such as BrowserStack Accessibility Linter.

- Drag this newly created build phase above Compile Sources step
- Delete any existing code in the newly created build step and add the following code.
- Add this script:
./browserstack-a11y-scan-spm.sh --include **/*.swift --non-strict
Xcode will now automatically run the accessibility scan during builds.
Press Cmd + B to build the project.
- If there are any Accessibility issues, then they will be show up in the Issue Navigator.

- The errors will also show up in the respective files, on the lines where the issue has occurred. Click on the cross mark to see the full error.

- If --non-strict flag is passed, the build will succeed even if there are Accessibility issues. If --non-strict flag is not passed, then the build will fail if there are Accessibility issues.
You can run accessibility checks automatically before each commit by running the following command.
./browserstack-a11y-scan-spm.sh register-pre-commit-hookYou can then edit the .git/hooks/pre-commit file to customise the registered pre-commit hook.
For any issues or feedback, reach out to [email protected]