Skip to content

Sentinel is a command line that can be integrated with Xcode using a Run Script Phase that allow present custom Warnings and Errors.

License

Notifications You must be signed in to change notification settings

ruiaureliano/Sentinel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚨Sentinel for Xcode

What is Sentinel

Sentinel is a command line that can be integrated with Xcode using a Run Script Phase that allow present custom Warnings and Errors.

Al rules are defined in a JSON file which is explained below.

Download or Build

1. Download Sentinel (1.0).

2. You can also build from source by cloning this project.

Installation

1. Open terminal and check your path

echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

2. Move sentinel to one of those directories, for instance /usr/local/bin, then in terminal, type this:

open /usr/local/bin

3. Drag sentinel to that folder, you may need to type your password

4. Close and reopen terminal and type this command: sentinel if you see the following message, that's all 💪

+----------------------------------------+
| USAGE: sentinel [debug|release] [json] |
| VERSION: 1.0                           |
+----------------------------------------+

Xcode Integration

Open Xcode project, navigate to Targets ► Build Phases, create a new Run Script Phase and enter this:

if which sentinel >/dev/null; then
    if [[ $CONFIGURATION == "Debug" ]]; then
        sentinel debug $SRCROOT/.debug.json
    elif [[ $CONFIGURATION == "Release" ]]; then
        sentinel release $SRCROOT/.release.json
    fi
else
    echo "warning: Sentinel not installed, download from https://github.com/ruiaureliano/Sentinel"
fi

Sentinel uses a JSON file with the rules for show warnings and errors, this particular file we use two separated JSON's, one for debug and one for release

Each JSON must be like this:

{
    "debug": [
        {
            "rule": "A = 1",
            "message": "⚠️ Yes can be a emoji 🤭",
            "type": "warning",
            "file": "*.swift"
        },
        {
            "rule": "(b|B) = 1",
            "message": "⚠️ Because '\\$1'",
            "type": "warning",
            "file": "*.swift"
        },
        {
            "rule": "if .* == true",
            "message": "⚠️ Avoid this, use 'if flag' instead",
            "type": "warning",
            "file": "*.swift"
        },
        {
            "rule": "if .* == false",
            "message": "⚠️ Avoid this, use 'if !flag' instead",
            "type": "warning",
            "file": "*.swift"
        }
    ]
}
{
    "release": [
        {
            "rule": "A = 1",
            "message": "🛑 Yes can be a emoji 🤭",
            "type": "error",
            "file": "*.swift"
        },
        {
            "rule": "(b|B) = 1",
            "message": "🛑 Because '\\$1'",
            "type": "error",
            "file": "*.swift"
        },
        {
            "rule": "if .* == true",
            "message": "🛑 Avoid this, use 'if flag' instead",
            "type": "error",
            "file": "*.swift"
        },
        {
            "rule": "if .* == false",
            "message": "🛑 Avoid this, use 'if !flag' instead",
            "type": "error",
            "file": "*.swift"
        }
    ]
}

The main key must be debug|release and the value is an array of dictionaries, where each one must have this keys: rule, message, type, file

Samples

1. Build and Run Samples project.

Output

1. When build

Warnings

2. When archiving

Errors


I'm Rui Aureliano, iOS and macOS Engineer at Olá Brothers. We make Sip 🤓

Linkedin | AngelList | Twitter | Github | Medium | Stackoverflow

About

Sentinel is a command line that can be integrated with Xcode using a Run Script Phase that allow present custom Warnings and Errors.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages