Questions tagged [swiftlint]

A tool to enforce Swift style and conventions, loosely based on GitHub's Swift Style Guide. SwiftLint hooks into Clang and SourceKit to use the AST representation of your source files for more accurate results.

A tool to enforce Swift style and conventions, loosely based on GitHub's Swift Style Guide. SwiftLint hooks into Clang and SourceKit to use the AST representation of your source files for more accurate results.

The tool verifies that your Swift code conforms to a set of rules syntactic rules defined by you and your teammates.

More details at SwiftLint Github.

185 questions
9
votes
1 answer

Swiftlint overriding project settings related to SPM

I am running into a strange behavior with swiftlint autocorrect. My project uses a library imported through SPM. But when I run the linter, it changes settings like the following B4621A7323D0A90F00545ADE /* LibraryName in Frameworks */ = {isa =…
user1366265
  • 1,306
  • 1
  • 17
  • 28
9
votes
2 answers

SwiftLint setup with Xcode

I am using a setup on Xcode that runs the following script for SwiftLint if which $PATH/swiftlint >/dev/null; then $PATH/swiftlint elif which $HOME/.brew/bin/swiftlint >/dev/null; then $HOME/.brew/bin/swiftlint elif which…
StackUnderflow
  • 107
  • 1
  • 4
8
votes
4 answers

Swiftlint underscore name swift

I use swiftlint in my project. The project name is ABC xx and it works fine with swiftlint. Now I decided to include Unitest in my application and I have to import @testable import ABC_xx into the swift test file which is class ABC_xxTests:…
King
  • 1,885
  • 3
  • 27
  • 84
8
votes
2 answers

Swiftlint autocorrect command not working

I have installed swiftlint using cocoapods and it is working properly But when I am trying to use swiftlint autocorrect command in the terminal, it is giving below error -bash: swiftlint: command not found Should I need to do any other setup to…
pradeep
  • 413
  • 2
  • 7
  • 20
8
votes
0 answers

NSMakeRange: Legacy Constructor Violation: Swift constructors are preferred over legacy convenience functions.

I am using the following code for providing with the line spacing between the UILabel text. let daysAttrString = NSMutableAttributedString(string: allDays) let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.lineSpacing = 7 …
Chelsea Shawra
  • 1,593
  • 4
  • 22
  • 43
7
votes
1 answer

SwiftLint -Disable Line Length Rules in a specific file

Current SwiftLint rules: file_length: warning: 800 error: 1500 The error I followed this answer but the error doesn't go away // swiftlint:disable force_cast import UIKit class MyClass: UIViewController { } // swiftlint:enable…
Lance Samaria
  • 17,576
  • 18
  • 108
  • 256
7
votes
2 answers

How to run swiftlint for git diff files only

I am working on an iOS Swift project. Git is being used for version controlling. I want to run swiftlint tool only for newly changed files. On other words, I want to check static issues only for the files that have been edited till last commit. If…
Sazzad Hissain Khan
  • 37,929
  • 33
  • 189
  • 256
7
votes
2 answers

SwiftLint integration on Xcode 7.3.1, and getting error on --config command for .yml file configuration

I have integrated SwiftLint using pods and its working fine to produce warnings and errors. But I want to configure .yml file. For this I use following command on terminal. swiftlint lint --config MyFile.yml and getting following error... fatal…
Mohsin Qureshi
  • 1,203
  • 2
  • 16
  • 26
7
votes
3 answers

How to uninstall swiftlint from xcode, or to turn its warnings off

Please help me to understand how to uninstal swiftlint, or how to switch it warnings off completely(because it starts to ignore all rules from time to time). I installed swiftilnt from pkg file, and now cannot find a way to remove it. "run from…
Stacy Grey
  • 73
  • 1
  • 1
  • 4
5
votes
7 answers

Command PhaseScriptExecution failed with a nonzero exit code Xcode 11.3.1

I am getting Command PhaseScriptExecution failed with a nonzero exit code error frequently, The below workarounds which I followed but didn't help me. Workaround1: Keychain Access -> Right-click on login -> Lock & unlock again -> Clean Xcode project…
OhStack
  • 106
  • 1
  • 1
  • 15
4
votes
2 answers

Swiftlint Autocorrect Does Not Modify File

In running swiftlint version 0.24.0, errors are reported. Running autocorrect states that the files have been corrected. Yet no modifications are made as a subsequent run of swiftlint proves. See the attempt to lint and correct two files…
Max MacLeod
  • 26,115
  • 13
  • 104
  • 132
4
votes
1 answer

How can I use swiftlint to enforce that every swift file must include a specified header values?

I wanted that every *.swift files must have the required texts. Like so.. If the developer forgets to add it or has inputted the wrong values swiftlint will give an error or warning upon compiling. I have searched about file_header but somehow it…
otakuProgrammer
  • 298
  • 2
  • 12
4
votes
1 answer

run-sonar-swift.sh with custom swiftlint .yml file

i have a problem with my .yml rules. I can include them into my project, he does get the custom rules, but I cannot show them in sonarqube, because he says he does not know the rules. can anyone help me? my .swiftlint.yml file is in the…
Auryn
  • 1,117
  • 1
  • 13
  • 37
4
votes
1 answer

swiftlint open brace rule

I'm using Swiftlint to enforce some practices in our codebase. I want to add a custom rule that makes sure a { always appears after a newline. I thought I knew regexes, but can't seem to figure it out. I just check if a line contains any characters…
Haagenti
  • 7,974
  • 5
  • 38
  • 52
3
votes
1 answer

(SwiftLint) How to write the rule (maybe custom) where it is always "\n"(new line) after the "{" if there is a body?

I am using SwiftLint and I need to have a new line after the "{" if there is a body, for example, this is correct func foo() { if true { } } but this doesn't seem right func foo() { if true { print("This print should be…
Sirop4ik
  • 4,543
  • 2
  • 54
  • 121
1 2
3
12 13