I am using swiftlint in Build phase - Run script. Build is failed because of swiftlint error. How can I proceed successful build but still want to produce swiftlint comments (i.e. errors, warnings) in my project?
3 Answers
You can either:
Change your config and remove the
error
limits, keeping only thewarning
limits:line_length: - 120 # warning limit - 200 # error limit
vs
line_length: 120 # warning limit
Change your build phases script to automatically convert errors to warnings, e.g.:
swiftlint lint --quiet $@ | sed 's/error: /warning: /g'
You cannot have an error and still the build. Also I suppose that you don't have "treat errors as warnings" build setting turned on.
- You can modify the rules of swiftlint with your own custom .swiftlint.yml in your project to make the error into a warning or completely ignore it swiftlint custom rules.
- Or you disable the rule for this one time with
// swiftlint:disable:next line_length
above your 1422 char line.
-
1Can I add disable rules as command line argument? i.e.
swiflint -disable comma
Commented May 3, 2019 at 8:06
Write this line above your error line.
// swiftlint:disable type_name
type_name will be your error name, in this case it will be
// swiftlint:disable line_length
-
1That wont be feasible for too many changes and it also make the code dirty. Commented May 3, 2019 at 8:07
-
If you don't want to do this then you should make file name .swiftlint.yml and update line_length in it. Commented May 3, 2019 at 9:57
swiftlint
using some tool (e.g.sed
) and converterror:
towarning:
automatically.