使用 Xcode 设置 SwiftLint

标签 swift swiftlint

我在 Xcode 上使用的设置为 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 ~/Softwares/homebrew/bin/swiftlint >/dev/null; then
~/Softwares/homebrew/bin/swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi

我无法使用pods或brew。

为了使 SwiftLint 可用,我使用以下命令将以下内容添加到我的路径中 vim ~/.bash_profile

export PATH
export PATH=$PATH:/Users/me/Documents/SwiftLint

我现在可以通过命令行在任何地方访问 SwiftLint

但是,Xcode 仍然显示未安装 SwiftLint 的消息。

我无法使用其他方法来安装 Swiftlint 或更改脚本。我猜我的导出路径有问题 - 这是什么问题?

最佳答案

运行脚本时,将不考虑.bash_profile。我会像这样添加你的脚本:

if test -d "${HOME}/Documents/SwiftLint"; then
  PATH="${HOME}/Documents/SwiftLint:${PATH}"
fi

export PATH

if ! which swiftlint >/dev/null 2>&1; then
    echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint" >&2
fi

关于使用 Xcode 设置 SwiftLint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58741453/

相关文章:

ios - Alamofire:失败响应序列化失败

macos - Swift 中的 Cocoa 授权

ios - 当键盘出现时移动 View 并在点击周围时再次隐藏

SwiftLint 在 Swift 中覆盖 getter 时收到 "implicit_getter"警告

ios - 如何从 xcode 卸载 swiftlint,或关闭它的警告

Swiftlint 自动更正不修改文件

ios - 使用核心数据时更新 Spotlight 搜索索引?

ios - 将两个类合并为一个类

swift - swiftlint :disable:next and swiftlint:disable:this? 和有什么区别

ios - 如何禁用 swiftlint 配置文件中的字符限制