Skip to content

Instantly share code, notes, and snippets.

@mdb1
Created July 23, 2023 15:12
Show Gist options
  • Save mdb1/d5b7c005af9989815281dc016cc5d138 to your computer and use it in GitHub Desktop.
Save mdb1/d5b7c005af9989815281dc016cc5d138 to your computer and use it in GitHub Desktop.
An Xcode BuildPhase to enforce a minimum SwiftLint version
if [[ "$(uname -m)" == arm64 ]]; then
export PATH="/opt/homebrew/bin:$PATH"
fi
SWIFTLINT_VERSION=$(swiftlint --version | awk '{print $NF}')
MIN_VERSION="0.52.4"
# Only run if `installed version` >= `minimum version`.
if [[ "$(printf '%s\n' "$MIN_VERSION" "$SWIFTLINT_VERSION" | sort -V | head -n1)" == "$MIN_VERSION" ]]; then
echo "SwiftLint version: $SWIFTLINT_VERSION"
swiftlint
else
echo "error: SwiftLint version $MIN_VERSION is required, but you have version $SWIFTLINT_VERSION installed. Run: brew install swiftlint"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment