如何在构建阶段脚本中产生致命错误

时间:2019-08-27 08:50:31

标签: swift xcode swiftlint

我尝试在lint脚本中造成致命错误。目前,我能够创建一个正常的错误,使我可以编译代码。 有什么办法可以在此脚本中创建致命错误?

if which swiftlint >/dev/null; then
    swiftlint
else
    echo "error: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi

1 个答案:

答案 0 :(得分:1)

如果生成脚本以非零退出状态终止,则Xcode生成过程将失败并显示错误:

if which swiftlint >/dev/null; then
    swiftlint
else
    echo "error: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
    exit 1
fi

或者只使用

swiftlint

作为构建脚本。如果未找到swiftlint程序,则构建过程也将失败,并显示类似

的错误消息
swiftlint: command not found
Command /bin/sh failed with exit code 127