DEV Community

Jakub Turek for EL Passion

Posted on

2 1

SwiftLint config per target

EL Passion ❤️ open source.

In our mission to deliver the highest quality product possible, the iOS team at EL Passion rely on linting tools such as SwiftLint to fix common code structuring & formatting issues.

However, there are some scenarios in which we can't easily employ the tooling to work for us. We've encountered this issue when developing VinylShop mobile app with the following directory structure:

Project /
├── Project.xcodeproj
└── Sources /
    └── Controllers /
       └── Login /
           ├── LoginViewController.swift
           └── LoginViewControllerSpec.swift

We couldn't easily configure SwiftLint to use a different configuration for the production and for the test files.

SwiftLint runner

Fortunately, we've been able to fix the issue by implementing a simple Python script which reads the contents of the .pbxproj file and modifies the included files in the SwiftLint config prior to the linting. The script is divided into the two simple files:

What's even better is that we've released the script as the PyPI package, so you can use it in your own projects, too. It's as simple as running:

pip install swiftlint-runner

And adding an appropriate build phase:

slrunner <project_name>.xcodeproj <target_name> .<swiftlint_config_file_name>.yml

You can find more details at the elpassion/swiftlint-runner repository.

License

SwiftLint runner is maintained with ❤️ by EL Passion and released under an MIT license.

Sentry mobile image

Improving mobile performance, from slow screens to app start time

Based on our experience working with thousands of mobile developer teams, we developed a mobile monitoring maturity curve.

Read more

Top comments (0)

Billboard image

📊 A side-by-side product comparison between Sentry and Crashlytics

A free guide pointing out the differences between Sentry and Crashlytics, that’s it. See which is best for your mobile crash reporting needs.

See Comparison

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay