Rui Aureliano
Rui Aureliano

Rui Aureliano

๐Ÿšจ Sentinel for Xcode

Rui Aureliano's photo
Rui Aureliano
ยทJun 5, 2019ยท

2 min read

Because of my last article and after some feedback (thanks @mattie) I decided to start Sentinel for Xcode

Why?? my previous approach was 100% pure shell script, which btw itโ€™s not simple to read, so since this is for Xcode, so letโ€™s do with swift ๐Ÿš€.

The project is public (github.com/ruiaureliano/Sentinel), feel free to try and comment ๐Ÿ’ช. There are two projects, Sentinel itself and a Sample project to test.

1) Download or Build Sentinel

You need to download the release or build the project itself, up to you

  1. Download Sentinel from this Release here.
  2. You can also build from source by cloning this project.

2) Installation

  1. Open terminal and check your path

1.png

  1. Move sentinel to one of those directories, for instance /usr/local/bin
  2. Drag sentinel to that folder, you may need to type your password
  3. Close and reopen terminal and type this command: sentinel if you see the following message, that's all ๐Ÿ’ช.

2.png

3) Xcode Integration

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

3.png

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

Each JSON must be like this:

4.png

5.png

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

Explaining JSON rules

The difference between .debug.json and .release.json is just the way we display messages, warnings, and errors

a) 1st rule is โ€œA = 1โ€ and we show a simple message โ€œโš ๏ธ Yes can be an emoji ๐Ÿคญโ€

b) 2nd rule โ€œb|B = 1โ€ will trigger a message if โ€œb=1โ€ or โ€œB=1โ€ we display this message โ€œโš ๏ธ Because โ€˜\\$1โ€™โ€

c) 3rd rule โ€œif .* == true {โ€ this rule explain how to use regular expressions, in this case we donโ€™t want to compare a flag with a bool, instead just use โ€œif flagโ€, not if โ€œflag == trueโ€

d) 4th rule, same as c) but for false

Output

6.png

7.png

Thanks, please share if you think this is awesome ๐Ÿง

Did you find this article valuable?

Support Rui Aureliano by becoming a sponsor. Any amount is appreciated!

Learn more about Hashnode Sponsors
ย 
Share this