SwiftLint 사용하기

개발 2022. 9. 23. 05:32
반응형

SwiftLint 사용하기

https://github.com/realm/SwiftLint

설치하기 위해서는 여러가지 방법이 있는데 개인적으로 Homebrew를 사용해서 설치합니다.

brew install swiftlint

command not found: brew

Homebrew가 설치가 되어 있지 않은 경우에는 Homebrew를 먼저 설치해줍니다.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

설치 확인

swiftlint --version
// 0.49.1 

Xcode에 프로젝트 Targets에서 Build Phases
Run Script 추가

export PATH="$PATH:/opt/homebrew/bin"
if which swiftlint > /dev/null; then
  swiftlint
else
  echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi

참고로, 명령어에 swiftlint autocorrect 넣어주면 기본적인 것들에 대한 자동으로 수정해줍니다. 

세부설정은 프로젝트 폴더에 .swiftlint.yml 을 사용해서 원하는데로 설정이 가능합니다.

swiftlint.yml
0.00MB

 

 

빌드 할때 다음과 같은 경고가 나오는 경우에는 

Run script 부분의 Based on dependancy analysis 를 체크 해제 해주면 됩니다.

반응형

'개발' 카테고리의 다른 글

Xcode 파일 생성시 Created by 이름 변경하기  (0) 2026.01.06
클린 아키텍처(Clean Architecture) 요약  (0) 2025.12.04
Xcode 26 변경점  (0) 2025.11.07
WWDC 2025 요약  (2) 2025.07.04
유지보수하기 어렵게 코딩하는 방법  (0) 2023.11.15
SOLID 원칙  (0) 2023.05.31
Posted by 까칠코더
,