Closed jshier closed 1 month ago
Redirecting the error output with 2>/dev/null
allows me to use --lint
without producing errors in Xcode, but it would be nice if there was a way to do that natively.
@jshier hmm, this isn't a use-case I'd considered. You could grep the stderr output from the lint command to see if it contained any warnings I suppose?
@jshier btw, do you also use SwiftLint as part of your workflow? Does it handle this differently?
Yes, we run SwiftLint, but just as a linter. It can directly take in the changed files and produce the output we want, sort of the opposite of SwiftFormat.
I can redirect the error output to /dev/null
(apparently Xcode interprets any error output from scripts as a build failure), like I said, and the script works fine, but it does seem strange that --lenient
even exists, as it seems to negate --lint
entirely. swiftformat --lint --lenient
will always succeed, no?
For my script to work I just need the error code output.
it does seem strange that --lenient even exists, as it seems to negate --lint entirely.
The intention of --lenient is to show warnings in Xcode without failing the build.
Huh, we never saw those. How are the warnings output? Does --quiet
filter them? In any case, for my usage I just need to know if there would be any changes after formatting, we don't want them inline in Xcode.
How are the warnings output?
They're just printed to stderr, but if you run SwiftFormat as a build phase script then they show up in the editor itself as warnings - same as for SwiftLint.
Did you manage to find a solution that works for you with the latest SwiftFormat changes? I'm loathe to revert this change because I consider it a correction to the previous wrong behaviour, but I also don't want to break your workflow.
Just redirecting the error output, which works fine.
@jshier --lint --quiet
should now work as before in 0.53.9
For a few months I'd run a
swiftformat
linting as part of my build to see whether I needed to manually format code (in order to avoid Xcode issues I don't format during build). Worked great until--lint
was changed to return error output that was visible in Xcode and broken the build. I added--lenient
, but then linting doesn't fail at all. Is there some sort of middle ground to make the script work again?Removing
lenient
from the command makes the errors show up in Xcode. I only want the failure code.