6

I'm looking for a tool to help the automation of best practices for Swift and iOS. One that can learn and enforce best practices, and enforce code style based on a set of custom or preset rules. The tool should detect bad indentation, when delegates or weak references are not nil'd out on deinit, use of syntax (Array<Element> vs [Element]), etc.

I've looked at both Faus Pas (Obj-C only) and Code Climate (web-based), but I'm looking for a program that works specifically with Swift, can be installed locally on our development machines, and can be integrated as a build step with Jenkins or CircleCI.

I'm potentially evaluating the analysis tools provided with AppCode, but I'm not sure how well they work with Swift. StyleCop looks like exactly what I want, is there a Swift equivalent?

I've modified my question slightly to include support for a mixed codebase containing both Objective-C and Swift (and potentially Objective-C++). The tools I have found previously only currently support Swift. As an alternative, I will also accept answers that use tools for each language that integrate nicely.

4

I've found SwiftLint and Tailor, which both enforce Swift style and convention best practices.

Both can be run from the command line as an external tool, or integrated with Xcode.

Both are well-maintained and Tailor is cross-platform. Both have customizable rules engines.

Tailor looks more "official," with a more stable dev team, but it's hard to say which tool is objectively "better."

I'm leaning more towards SwiftLint, as it gives you the ability to configure rules as well as specific project directories to lint from a YAML file in your project directory.

As far as Objective-C tools compatible with Swift, JP Simard, the author of SwiftLint, suggested using Clang Format as as similar tool for Objective-C in hybrid projects.

2

You could take a look at:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.