First Swift Lint

"Let's introduce SwiftLint soon" I got the advice, so I tried it!

Articles for such people

・ I'm not sure about everything after starting Swift ・ But somehow I came to understand a little

What is SwiftLint?

SwiftLint is said to be "swift's static analysis tool". What is static analysis? ??

[What are "dynamic tests" and "static tests" that I can't hear anymore? ] (https://hldc.co.jp/blog/2018/03/29/1211/) So that's it. It's a tool that you can check on occasion. Apparently, there are many items to be pointed out because it is checked on an occasional basis.

Let's do it now.

I actually tried it

For the introduction of SwiftLint, I felt that I needed an environment where I could use any of Mint, Homebrew, and CocoaPods. I thought, "Oh, what's that? Then I have to look it up." A big senior at the salon said that it's easiest to do it here. I tried to do as I was told.

First, access the location of SwiftLint. 1.png

Obviously, it's all in English. I think I'll get used to it soon, but toddlers will be "hey yeah yeah". I became

Scroll down and go down a little, 2.png There is a section "Using a pre-built package:". If you rely on Google Translate for the English in the above figure

Using pre-built packages:

You can also install SwiftLint by downloading and running it from the latest GitHub release SwiftLint.pkg.

Was translated. Hmmmm. I wonder if I should click the link and download "SwiftLint.pkg" or something. I will try it immediately. Click the link スクリーンショット 2021-01-18 21.33.03.png I jumped to the English page. From here, scroll down and you'll find it! !! 3-SwiftLintpkg.png

Click SwiftLint.pkg. It takes about 5 minutes to download, so take a break here. When the download is finished and you try to unzip it by double-clicking from the download folder, A warning will appear saying, "This is the one I haven't confirmed, so I can't open it."

Fufufu. I won't stumble there anymore. (Experienced in the past) From Finder, go to the download folder and コントロールを押しながら開く.png

Click __ "control" while pressing the corresponding "SwiftLint.pkg". Then, the place to open will appear, so click as usual. Then, a different alert will come out. 5.png

"Yes. Of course, it will open." This is cool, but it says, "It's okay because everyone is using it!" In the current state of affliction, click __ "Open" __ without any doubt. It can't be helped, I'm a beginner. I believe that one day I will be able to make well-founded decisions.

Now, let's launch a project that we would like to verify (which could be used for experiments). Select the folder at the top of your project to open a screen like this. スクリーンショット 2021-01-18 21.41.24.png Then, the outline of this project will be projected, so Top menu bar スクリーンショット 2021-01-18 21.43.08.png Open "Build Phases" here. It seems to read as build phase. Click on __ "+" __ at the bottom left of the figure above, __ Click New Run Script Phase __.

Then, in __Run Script __, A place where you can write code will appear. Copy and paste the code below there.

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

And as it is __ "⌘ + B" __! !!

Then how about! !! Without SwiftLint, this project had a few errors! !!

スクリーンショット 2021-01-18 21.53.02.png

We have unearthed _44 issues! !! _

I noticed it thinly. There is a problem with the layout ... Good when built on iPhone 11, but when built on iPod The layout was messed up ...

With that said, I thought I should patiently cultivate these issues. There were too many issues and I was hit by sleep, so I'll do it tomorrow ...

I didn't understand! !!

・ Do you copy and paste this every time? ?? Is it possible to import and put it in Xcode from the beginning? ・ Is there an easy way to translate this Warning error statement? ??

Well, it means getting used to English. It seems that the error display can also be customized by setting. I wanted to use it a little more and investigate it to learn better usage.

That's all for today.

Recommended Posts

First Swift Lint
[Swift] First Firebase
Swift Combine First step
[Swift] Type type-Class first part-
First post
[Swift] Closure
First post
First post
First java.util.logging