如何修复 Xcode 中由 swiftlint 引起的“尾随空白违规”警告?

Mal*_*ora 12 xcode ios swift swiftlint

我们如何一次性修复我的 iOS 项目中由 swiftlint 引起的“尾随空白违规”警告?我不想手动更正它们中的每一个。此外,我不想禁用这些警告,因此您可以跳过该建议。

我一直在尝试查找和替换选项,但我没有得到正确的关键字来解决这个问题。

图片 :

在此处输入图片说明

小智 41

While editing选中部分中的 2 个复选框

在此输入图像描述


Joa*_*son 24

swiftlint has an autocorrect option that will fix some issues for you, so when I get trailing whitespace warnings I run swiftlint from the command line in my project

$ swiftlint autocorrect
Run Code Online (Sandbox Code Playgroud)

Update

As of version 0.43 autocorrect has been deprecated and replaced with --fix so now the command is

$ swiftlint --fix
Run Code Online (Sandbox Code Playgroud)

autocorrect is still available for the time being, for more info see the change log


小智 12

要修复现有(从中删除尾随空白)纯空白行,按照 rmaddy 的建议打开首选项 include-whitespace-only-lines 后,可以选择全部,复制整个文件,然后粘贴,用相同的内容替换所有文本文本。Xcode 将在粘贴的代码上应用首选项。