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
- Custom Clang plugin shows lint warnings directly in Xcode at compile time
- Built escape hatch using custom annotations for legitimate rule exceptions
- Created Texture-specific rules to prevent common AsyncDisplayKit performance issues
- JSON config enables different rule sets for dev versus build machines
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.
About This Article
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.
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.
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.