라벨이 swiftLint인 게시물 표시

[iOS] swift lint를 코코아 팟 없이 사용하기

이미지
[iOS] swift lint를 코코아 팟 없이 사용하기 스위프트로 프로그래밍을 하면서 swift 코딩스타일 에 맞춰서 코딩을 하도록 도와줄 장치를 찾아보니 swiftLint를 만나게 되었습니다. 사용 방법에 대한 설명을 공식문서 에 제일 잘 나와있기 때문에 첨부만 해 놓겠습니다. 기존의 프로젝트와는 다르게 코딩의 규칙은 설치되어 있어야 하기 때문에 $ brew install swiftlint 로 설치 해줍니다. Xcode를 실행해서 타겟에 새로운 "Run Script"을 눌러서 추가해 줍니다. if which swiftlint >/dev/null; then swiftlint else echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint" fi 설치 후 실행하면 에러나 워닝들이 빡! autocorrect 옵션을 추가해주면, 빌드 했을 때 autocorrect 해줍니다. if which swiftlint >/dev/null; then swiftlint autocorrect else echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint" fi 빈 파일을 추가해 줍니다. 이름은 반드시 .swiftlint.yml 여야 합니다. 그리고 추가한 파일 안에 규칙들을 적어놓습니다. 규칙 보러가기 # By default, SwiftLint uses a set of sensible default rules you can adjust: disabled_rules: # rule identifiers turned on by default to exclude from running - colon - co