Pinterest Michael Schneider Jun 23, 2017

iOS Linting at Pinterest

Article Summary

Michael Schneider from Pinterest built a custom linting system that catches iOS code issues at compile time, not code review. The secret? Clang plugins that hook directly into the compiler's AST.

Pinterest's iOS team needed to enforce coding standards across a rapidly growing codebase with new engineers joining weekly. Off-the-shelf linters weren't flexible enough, so they built PINLinter using Clang's plugin infrastructure to provide instant feedback during compilation.

Key Takeaways

Critical Insight

Pinterest built a custom Clang-based linter that catches code quality issues at compile time, providing immediate developer feedback and enforcing framework-specific best practices.

The article reveals why they had to use a custom Clang binary instead of Xcode's built-in compiler, and the surprising workaround they needed.

About This Article

Problem

Pinterest's iOS team looked at existing linting tools but couldn't find one that worked well with their new Bazel build system and could report issues at compile time.

Solution

Michael Schneider's team built PINLinter using Clang Plugins instead of LibClang or LibTooling. It's a single dynamic library that reads linting rules from a JSON configuration file during compilation.

Impact

Developers caught problems like unsafe Objective-C pointer assignments and Texture anti-patterns right in Xcode instead of waiting for code review. This improved code quality and made the team happier.