Skip to content

Instantly share code, notes, and snippets.

@aiKrice
Created May 19, 2024 15:06
Show Gist options
  • Select an option

  • Save aiKrice/8fecd605309cfe4e88bbf5af53684c21 to your computer and use it in GitHub Desktop.

Select an option

Save aiKrice/8fecd605309cfe4e88bbf5af53684c21 to your computer and use it in GitHub Desktop.
Xcode build phase running with baseline
#!/bin/sh
#filter unstaged swift files
unstaged_swift_files_relative=$(git status --porcelain | grep -e '^[^\sD]' | grep '\.swift$' | cut -c4- | grep -v '^githooks/')
#filter staged swift files
staged_swift_files_relative=$(git diff --cached --name-only --diff-filter=d | grep '\.swift$' | grep -v '^githooks/')
#Removed duplication with both staged and unstaged files
all_swift_files=$(echo "$staged_swift_files_relative" "$unstaged_swift_files_relative" | sort | uniq)
#Launch only on working files
for file in $all_swift_files
do
/opt/homebrew/bin/swiftlint lint --silence-deprecation-warnings --baseline path/to/baseline.json --config .swiftlint.yml $(realpath "$file") --quiet
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment