realm / SwiftLint

A tool to enforce Swift style and conventions.
https://realm.github.io/SwiftLint
MIT License
18.64k stars 2.22k forks source link

Slow build #3991

Closed drekka closed 2 years ago

drekka commented 2 years ago

New Issue Checklist

Describe the bug

When using swift build ... during a build phase, SwiftLint takes a really long time to build.

I'm following to add SwiftLint to a project using SPM along with Rswift and SwiftFormat tools.

RSwift and SwiftFormat are relatively quick to build their command line executables where as SwiftLint takes it least 10 times longer. Mostly it would appear, in building dependencies such as SourceKitten.

Basically I'm using the script:

SDKROOT=`xcrun --sdk macosx --show-sdk-path`
swift build -c release --package-path BuildTools --product swiftlint --sdk $SDKROOT

Is there anyway to speed up building? On a fresh checkout it's taking minutes and even on a rebuild SwiftLint still takes at least 60 seconds build.

marcelofabri commented 2 years ago

It’s not a goal of SwiftLint to compile fast enough that it can be compiled in a build phase. Typically, you would run a precompiled version of SwiftLint in this case.

drekka commented 2 years ago

Hmmm. The build is Xcode and we want SwiftLint to run for developers so it's a build phase. But when this is run on CI it has to download/install SwiftLint first. So how do we achieve this?

marcelofabri commented 2 years ago

I recommend using a pre-compiled version if speed is important: either hosting the binary yourself, downloading from GitHub releases, using Homebrew, etc