Search code examples
swiftxcodeswiftlint

How make fatal error in build phases script


I try make fatal error in lint script. Currently I am able to create a normal bug that allows me to compile the code. Is there any way to create a fatal error in this script?

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

Solution

  • The Xcode build process fails with an error if a build script terminates with a non-zero exit status:

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

    Alternatively use just

    swiftlint
    

    as build script. If the swiftlint program is not found then the build process will also fail, with an error message like

    swiftlint: command not found
    Command /bin/sh failed with exit code 127