@@ -10,11 +10,16 @@ AccessibilityDevTools enables static accessibility linting directly inside Xcode
1010* 🛠 ** Inline errors inside Xcode** with remediation guidance
1111* ⚡ ** Runs during build** using the SPM command plugin
1212
13+ ---
14+ ## Supported projects types
15+ 1 . Projects created with Swift package manager
16+ 2 . Projects created with XCode
17+
1318---
1419## Authentication
15201 . Log in to your BrowserStack account or [ sign up] ( https://www.browserstack.com/users/sign_in ) if you don’t have an account.
16212 . Obtain your ** Username** and ** Access Key** from the [ Account & Profile section] ( https://www.browserstack.com/accounts/profile/details ) section on the dashboard.
17- ![ Account & Profile section] ( ./resources/a31150e8-6beb-4541-bc2a-e1d9f03e431d .png " Account & Profile section ")
22+ ![ Account & Profile section] ( ./resources/accounts .png " Account & Profile section ")
1823
19243 . Set the following environment variables using the ** Username** and ** Access Key** you obtained in step 2.
2025 * ` BROWSERSTACK_USERNAME `
@@ -38,79 +43,123 @@ AccessibilityDevTools enables static accessibility linting directly inside Xcode
3843
3944---
4045# # Installation
41- # ## SwiftPM Projects
42- For SwiftPM projects, you can use the SPM ` command plugin ` for Accessibility DevTools .
46+ # ## 1. Projects created with XCode
47+ > Note: XCode projects don’t have a Package.swift file. 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 .
4348
44- ** Add plugin in your ` Package.swift` **
49+ # ### Clone Script
50+ Run the following command at the < span style=" color:red" > root of your repository< /span>
4551
46- Edit the ` Project.swift` to include following code. Specifically, these two things to be added
52+ Zsh
53+ ` ` ` zsh
54+ 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.sh
55+ ` ` `
4756
48- * Add ` AccessibilityDevTools` as a package under dependencies
57+ Bash
58+ ` ` ` bash
59+ 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.sh
60+ ` ` `
61+
62+ Fish
63+ ` ` ` fish
64+ 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
65+ ` ` `
66+
67+ # ### Add a Build Phase
68+ Repeat these steps for each target in your project
4969
70+ 1. Select a target from the targets left sidebar and go to Build Phases tab
71+ 2. Click + to create a new build phase. Name the newly created build phase to a name such as ** BrowserStack Accessibility Linter** .
72+ ! [Build Phase](./resources/build-phase.png " Build Phase" )
73+ 3. Drag this newly created build phase above ** Compile Sources** step
74+ 4. Delete any existing code in the newly created build step and add the following code.
75+ 5. Add this script:
76+ ` ` `
77+ ./browserstack-a11y-scan-spm.sh --include ** /* .swift --non-strict
78+ ` ` `
79+ Xcode will now automatically run the accessibility scan during builds.
80+
81+ # ## 2. Projects created with Swift package manager
82+ ** Register plugin as dependency in your ` Package.swift` file**
83+
84+ Edit the ` Package.swift` to include following code. Specifically, add these two things:
85+
86+ * Add ` AccessibilityDevTools` as a package under dependencies
5087* Add ` a11y-scan` as a plugin under each target that you have in your project
5188
5289` ` ` swift
5390let package = Package(
54- name: " MySPMProject" ,
55- dependencies: [
56- .package(url: " https://github.com/browserstack/AccessibilityDevTools.git" , from: " 1.0.0" )
91+ name: " MyProject" ,
92+ // platforms, products, etc.
93+ dependencies: [
94+ // other dependencies
95+ .package(
96+ url: " https://github.com/browserstack/AccessibilityDevTools.git" ,
97+ branch: " main"
98+ ),
5799 ],
58100 targets: [
59- .executableTarget(
60- name: " MyApp" ,
61- dependencies: [],
62- plugins: [
63- .plugin(name: " a11y-scan" , package: " AccessibilityDevTools" )
64- ]
101+ .executableTarget(
102+ name: " MyApp" ,
103+ dependencies: [],
104+ plugins: [
105+ .plugin(
106+ name: " a11y-scan" ,
107+ package: " AccessibilityDevTools"
108+ )
109+ ]
65110 )
66111 ]
67112)
68113` ` `
69- ** Add a Build Phase to run the plugin**
70- 1. Select first item (project root) in the left folder tree and go to Build Phases tab
71- ! [Build Phases](./resources/25519c9c-87a9-41af-b97b-23f875faf3b7.png " Build Phases" )
72- 2. Click + to create a new build phase. Name the newly created build phase to a name such as ** BrowserStack Accessibility Linter**
73- 3. Drag this newly created build phase above ** Compile Sources** step
74- 4. Delete any existing code in the newly created build step and add the following code.
75- 5. Add this script:
76- ` ` ` bash
77- /usr/bin/xcrun swift package scan --disable-sandbox --include ** /* .swift
78- ` ` `
79114
80- Xcode will now automatically run the accessibility scan during builds.
115+ # ### Clone Script
116+ Run the following command in the < span style=" color:red;" > root of your repository< /span>
117+
118+ Zsh
119+ ` ` ` zsh
120+ 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.sh
121+ ` ` `
81122
82- # ## Non-SwiftPM Projects
83- For all non-SwiftPM projects (e.g. Xcode projects), you can use the ** browserstack-cli**
123+ Bash
124+ ` ` ` bash
125+ 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.sh
126+ ` ` `
84127
85- ** Install CLI in the project repo**
86- 1. Open terminal and navigate to the project folder.
87- 2. Run the commands provided in the [documentation](https://www.browserstack.com/docs/accessibility-dev-tools/run-checks-cli#install-the-cli)
128+ Fish
129+ ` ` ` fish
130+ 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
131+ ` ` `
88132
89- ** Disable Sandboxing**
90- 1. In Xcode project, select first item (project root) in the left folder tree and go to Build Settings tab
91- 2. Search for sandbox > Set user script sandboxing to “NO”
133+ # ### Add a Build Phase
134+ Repeat these steps for each target in your project
92135
93- ** Add a Build Phase to run the plugin**
94- 1. Select first item (project root) in the left folder tree and go to Build Phases tab
95- ! [Build Phases](./resources/25519c9c-87a9-41af-b97b-23f875faf3b7.png " Build Phases" )
136+ 1. Select a target from the targets left sidebar and go to Build Phases tab
961372. Click + to create a new build phase. Name the newly created build phase to a name such as ** BrowserStack Accessibility Linter**
138+ ! [Build Phase](./resources/build-phase.png " Build Phase" )
971393. Drag this newly created build phase above ** Compile Sources** step
98- 4. Delete any existing code in the newly created build step and add the following code.
140+ 4. Delete any existing code in the newly created build step and add the following code.
991415. Add this script:
100- ` ` ` bash
101- ./browserstack-cli accessibility --include ** /* .swift
102142` ` `
143+ ./browserstack-a11y-scan-spm.sh --include ** /* .swift --non-strict
144+ ` ` `
145+ Xcode will now automatically run the accessibility scan during builds.
103146
104147---
105148# # Running Accessibility Scans
106- Press Cmd + B to build the project. If there are no errors from the linter (and any other build steps you have), the build will succeed.
149+ Press Cmd + B to build the project.
150+ * If there are any Accessibility issues, then they will be show up in the Issue Navigator.
151+ ! [Issue Navigator](./resources/issue-navigator.png " Issue Navigator" )
152+ * 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.
153+ ! [Issue Details](./resources/issue-details.png " Issue Details" )
154+ * 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.
107155
108- If issues are found:
109-
110- * Inline red markers show errors in files. Click on the cross mark to see the full error.
111- ! [Diagnostics](./resources/bb7fbc3b-6d19-47e9-93c5-8c4b0ae124a6.png " Diagnostics" )
112- * All issues appear in the ** Issue Navigator**
113- ! [Issue Navigator](./resources/ff9e25c4-0d57-4423-ae0f-fa77b56d99a7.png " Issue Navigator" )
156+ ---
157+ # # Register pre-commit hook
158+ You can run accessibility checks automatically before each commit by running the following command.
159+ ` ` ` bash
160+ ./browserstack-a11y-scan-spm.sh register-pre-commit-hook
161+ ` ` `
162+ You can then edit the ` .git/hooks/pre-commit` file to customise the registered pre-commit hook.
114163
115164---
116165# # Support
0 commit comments