This content originally appeared on DEV Community and was authored by Liang Wang
I noticed that SwiftLint no longer works for me in Xcode 15.4 when I switched to a M1 Mac, so I searched and found this user script that has helped me to resolve this problem.
Install SwiftLint
brew install swiftlint
Add new run script phrase
if [[ "$(uname -m)" == arm64 ]]; then
export PATH="/opt/homebrew/bin:$PATH"
fi
if which swiftlint > /dev/null; then
swiftlint --fix && swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
Disable User Script Sandboxing
Do not forget to disable User Script Sandboxing in Build Settings/Build options, which is enabled by default from XCode 15.
Swiftlint rules
Update the line_length warning and error so it works for you.
disabled_rules:
- trailing_whitespace
opt_in_rules:
- empty_count
- empty_string
excluded:
- Carthage
- Pods
- SwiftLint/Common/3rdPartyLib
line_length:
warning: 300
error: 500
ignores_function_declarations: true
ignores_comments: true
ignores_urls: true
function_body_length:
warning: 300
error: 500
function_parameter_count:
warning: 10
error: 15
type_body_length:
warning: 300
error: 500
file_length:
warning: 1000
error: 1500
ignore_comment_only_lines: true
cyclomatic_complexity:
warning: 15
error: 25
reporter: "xcode"
SwiftLint disable rule
For example, // swiftlint:disable:next identifier_name
This content originally appeared on DEV Community and was authored by Liang Wang

Liang Wang | Sciencx (2024-08-06T18:09:17+00:00) Add SwiftLint to Xcode 15.4 on M1 mac. Retrieved from https://www.scien.cx/2024/08/06/add-swiftlint-to-xcode-15-4-on-m1-mac/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.