반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- UIScrollView
- 문자열
- SwiftLint
- 다크모드
- LazyHStack
- NavigationLink
- RxSwift
- Java
- remote config
- WebView
- Swift
- Android
- swipe
- Firebase
- SwiftUI
- subscript
- gcd
- Realtime Database
- string
- Apple
- 웹뷰
- autolayout
- 라이트모드
- UIButton
- UITabBarController
- github
- dictionary
- Observable
- Alamofire
- ios
Archives
- Today
- Total
점진적 과부하 개발 블로그
SwiftLint 알아보기 본문
반응형
SwiftLint 알아보기
SwiftLint 란
- 하나의 Xcode내에서 Swift의 코드 스타일을 통합시킬수 있도록 도와주는 프레임워크이다.
- https://github.com/realm/SwiftLint
GitHub - realm/SwiftLint: A tool to enforce Swift style and conventions.
A tool to enforce Swift style and conventions. Contribute to realm/SwiftLint development by creating an account on GitHub.
github.com
- 강제로 NSObject를 Int형으로 타입 캐스팅을 시도하는 코드이다, 만약 실패하게 되면 앱이 크래쉬가 발생되는 아주 극단적인 코드이다.
- 이런 코드를 SwiftLint가 강제적으로 컴파일 에러를 시켜서 Xcode가 작동을 못하게 한다.
- 두번째 코드는 스페이스바의 위치가 잘못되어있는 경우 SwiftLint가 주의를 주는 모습을 볼 수 있습니다.
이것 말고도 file_length: 의 관한 줄 수도 설정할 수 있다.
file_length:
waring: 500 // Swift 파일의 줄 수가 500줄 이상이면 경고
error: 1200 // Swift 파일의 줄 수가 1200줄 이상이면 error
Xcode내에 .swiftlint,yml 파일을 추가하고 아래와 같은 코드를 입력해주면 커스텀 또한 가능하다.
# configurable rules can be customized from this configuration file
# binary rules can set their severity level
force_cast: warning # implicitly
force_try:
severity: warning # explicitly
# rules that have both warning and error levels, can set just the warning level
# implicitly
line_length: 110
# they can set both implicitly with an array
type_body_length:
- 300 # warning
- 400 # error
# or they can set both explicitly
file_length:
warning: 500
error: 1200
반응형
'Swift' 카테고리의 다른 글
네이버 영화 API 사용하기 (0) | 2022.07.07 |
---|---|
SwiftLint 설치 방법 (0) | 2022.07.05 |
SwiftUI NavigationLink 활용 (0) | 2022.07.01 |
Swift 한글이 포함된 url 처리하기 (0) | 2022.06.29 |
Swift Lazy Stored Properties (지연 저장된 프로퍼티) (0) | 2022.06.26 |