Agent skills for iOS, iPadOS, Swift, SwiftUI, and modern Apple framework development.
71
89%
Does it follow best practices?
Impact
—
No eval scenarios have been run
Advisory
Suggest reviewing before use
Setup instructions for each SwiftLint integration method: build tool plugin, command plugin, Xcode run scripts, CI, and secondary integrations.
The SwiftLintBuildToolPlugin from SimplyDanny/SwiftLintPlugins runs SwiftLint as part of the build. No Homebrew or PATH setup needed.
// Package.swift
let package = Package(
name: "MyApp",
dependencies: [
.package(url: "https://github.com/SimplyDanny/SwiftLintPlugins", from: "<reviewed-version>")
],
targets: [
.target(
name: "MyApp",
plugins: [.plugin(name: "SwiftLintBuildToolPlugin", package: "SwiftLintPlugins")]
),
.testTarget(
name: "MyAppTests",
dependencies: ["MyApp"],
plugins: [.plugin(name: "SwiftLintBuildToolPlugin", package: "SwiftLintPlugins")]
)
]
)https://github.com/SimplyDanny/SwiftLintPluginsSwiftLintBuildToolPlugin under Run Build Tool Plug-insOn first build, Xcode shows a trust dialog. Select Trust & Enable All for the SwiftLintPlugins package. In CI with xcodebuild, pass:
xcodebuild -skipPackagePluginValidation -skipMacroValidation ...--fix (it has read-only access to sources).--baseline or other CLI flags — build tool plugins do not accept arguments. Use config keys like baseline: / write_baseline: where available, or switch to the command plugin / direct CLI for advanced flag-based workflows.The command plugin provides broad SwiftPM-based CLI access to SwiftLint, including --fix, --baseline, and analyze workflows that the build tool plugin cannot handle directly:
swift package plugin swiftlint
swift package plugin swiftlint --fix
swift package plugin swiftlint -- --strict --baseline .swiftlint.baseline
swift package plugin swiftlint -- analyze --compile-commands .build/debug.yamlThe command plugin requires the same SwiftLintPlugins dependency. It has read-write access to sources (for --fix) and accepts all CLI flags after --.
Use a run script when the build tool plugin is impractical for your project shape or when you need CLI features the build tool plugin cannot provide (for example --fix locally or --baseline). Xcode projects can still use the build tool plugin via Xcode Package Dependency even without a local Package.swift.
if command -v swiftlint >/dev/null 2>&1; then
swiftlint
else
echo "warning: SwiftLint not installed. Install with: brew install swiftlint"
fiOn Apple Silicon with Homebrew, swiftlint is often installed at /opt/homebrew/bin/swiftlint. If the run script cannot find it, either export that path in the build phase or create a symlink into /usr/local/bin:
if [[ "$(uname -m)" == arm64 ]]; then
export PATH="/opt/homebrew/bin:$PATH"
fi
if command -v swiftlint >/dev/null 2>&1; then
swiftlint
else
echo "warning: SwiftLint not installed. Install with: brew install swiftlint"
fiXcode 15 sandboxes run scripts by default. If SwiftLint fails with Sandbox: swiftlint ... deny(1) file-read-data, set ENABLE_USER_SCRIPT_SANDBOXING = NO for the target. Input files and input file lists are a separate optimization for limiting which files are linted.
ENABLE_USER_SCRIPT_SANDBOXING = NO for the target if the script cannot read source files under Xcode 15+.xcfilelist paths under Input File Lists--use-script-input-file-lists when Xcode is providing .xcfilelist paths:if command -v swiftlint >/dev/null 2>&1; then
swiftlint --use-script-input-file-lists
fiThis requires Xcode to populate SCRIPT_INPUT_FILE_LIST_COUNT and SCRIPT_INPUT_FILE_LIST_n with readable .xcfilelist paths. Use --use-script-input-files only when Xcode is populating SCRIPT_INPUT_FILE_COUNT and SCRIPT_INPUT_FILE_n directly via Input Files rather than Input File Lists.
Alternatively, to lint the full target without file lists:
if command -v swiftlint >/dev/null 2>&1; then
swiftlint lint --config "${SRCROOT}/.swiftlint.yml"
fiAnd uncheck Based on dependency analysis if you want it to run every build.
"${PODS_ROOT}/SwiftLint/swiftlint"name: SwiftLint
on:
pull_request:
paths: ['**/*.swift']
jobs:
lint:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Install SwiftLint
run: brew install swiftlint
- name: Lint
run: swiftlint --strict --reporter github-actions-loggingFor SARIF upload to GitHub code scanning:
- name: Lint (SARIF)
run: swiftlint --strict --reporter sarif > swiftlint.sarif
continue-on-error: true
- name: Upload SARIF
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: swiftlint.sarif- name: Lint (baseline)
run: swiftlint --strict --baseline .swiftlint.baseline --reporter github-actions-loggingswiftlint:
image: ghcr.io/realm/swiftlint:latest
script:
- swiftlint --strict --reporter codeclimate > swiftlint.json
artifacts:
reports:
codequality: swiftlint.jsonIf you want GitLab JUnit-style output instead, use --reporter gitlab and publish the result as a JUnit artifact rather than codequality.
brew install swiftlint
swiftlint --strict| Reporter | Format | Best for |
|---|---|---|
xcode | Xcode-compatible text | Local builds, Xcode run scripts |
github-actions-logging | GitHub Actions annotations | PR inline comments |
sarif | SARIF JSON | GitHub code scanning |
json | JSON array | Custom tooling, dashboards |
checkstyle | XML | Jenkins, SonarQube |
csv | CSV | Spreadsheet analysis |
emoji | Text with emoji | Fun terminal output |
SwiftLint is predominantly SwiftSyntax-based, but some rules still rely on SourceKit/Clang for additional analysis. It must remain compatible with the Swift toolchain used to compile your project.
Key rules:
XCODE_DEFAULT_TOOLCHAIN_OVERRIDE, TOOLCHAIN_DIR or TOOLCHAINS, xcrun -find swift, /Applications/Xcode.app/..., /Applications/Xcode-beta.app/..., ~/Applications/Xcode.app/..., ~/Applications/Xcode-beta.app/....DEVELOPER_DIR before running SwiftLint:export DEVELOPER_DIR=/Applications/Xcode_16.app/Contents/Developer
swiftlintsourcekitd.framework is expected in the selected toolchain’s usr/lib/ directory. Toolchain mismatches typically show up as parsing or SourceKit failures.The SwiftLint VS Code extension runs SwiftLint on save.
// .vscode/settings.json
{
"swiftlint.enable": true,
"swiftlint.path": "/opt/homebrew/bin/swiftlint",
"swiftlint.autoLintWorkspace": false
}# Fastfile
lane :lint do
swiftlint(
mode: :lint,
config_file: ".swiftlint.yml",
strict: true,
raise_if_swiftlint_error: true
)
endThe official SwiftLint Docker image is useful for Linux CI:
docker run --rm -v "$(pwd):/work" -w /work ghcr.io/realm/swiftlint:<reviewed-version> --strict# .pre-commit-config.yaml
repos:
- repo: https://github.com/realm/SwiftLint
rev: <reviewed-version>
hooks:
- id: swiftlintTo apply fixes and fail on warnings/errors from the hook, use an entry override:
# .pre-commit-config.yaml
repos:
- repo: https://github.com/realm/SwiftLint
rev: <reviewed-version>
hooks:
- id: swiftlint
entry: swiftlint --fix --strict#!/bin/sh
# .git/hooks/pre-commit
if command -v swiftlint >/dev/null 2>&1; then
git diff --cached --name-only --diff-filter=d -- '*.swift' | \
xargs -I{} swiftlint lint --path "{}" --strict --quiet
fiMake it executable: chmod +x .git/hooks/pre-commit
skills
accessorysetupkit
references
activitykit
references
adattributionkit
references
alarmkit
references
app-clips
app-intents
references
app-store-optimization
app-store-review
apple-on-device-ai
appmigrationkit
references
audioaccessorykit
references
authentication
references
avkit
references
background-processing
references
browserenginekit
references
callkit
references
carplay
references
cloudkit
references
contacts-framework
references
core-bluetooth
references
core-data
core-motion
references
core-nfc
references
coreml
references
cryptokit
references
cryptotokenkit
references
debugging-instruments
device-integrity
references
dockkit
references
energykit
references
eventkit
references
financekit
references
focus-engine
gamekit
references
healthkit
references
homekit
references
ios-accessibility
ios-localization
ios-networking
ios-simulator
references
mapkit
metrickit
references
musickit
references
natural-language
references
paperkit
references
passkit
references
pdfkit
references
pencilkit
references
permissionkit
references
photokit
push-notifications
realitykit
references
relevancekit
references
scenekit
references
sensorkit
references
speech-recognition
spritekit
references
storekit
swift-api-design-guidelines
swift-architecture
swift-charts
references
swift-codable
swift-concurrency
swift-formatstyle
swift-language
swift-security
references
swift-testing
swiftdata
swiftlint
swiftui-animation
swiftui-gestures
references
swiftui-layout-components
swiftui-liquid-glass
references
swiftui-patterns
swiftui-performance
swiftui-uikit-interop
swiftui-webkit
tabletopkit
references
tipkit
references
vision-framework
weatherkit
references
widgetkit
references