Search code examples
swiftswiftlint

SwiftLint causing build failed


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?

enter image description here


Solution

  • You can either:

    1. Change your config and remove the error limits, keeping only the warning limits:

      line_length:
        - 120 # warning limit
        - 200 # error limit
      

      vs

      line_length: 120 # warning limit
      
    2. 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.