Skip to content

Add cifilter-builtins style guide rule#376

Open
stephenfurlani-cell wants to merge 1 commit intoairbnb:masterfrom
stephenfurlani-cell:sjf--swift-style--cifilter-builtins
Open

Add cifilter-builtins style guide rule#376
stephenfurlani-cell wants to merge 1 commit intoairbnb:masterfrom
stephenfurlani-cell:sjf--swift-style--cifilter-builtins

Conversation

@stephenfurlani-cell
Copy link
Copy Markdown

Prefer CIFilter typed factory methods (CIFilterBuiltins) over string-based CIFilter(name:) and setValue(_:forKey:). Adds rule entry to the Patterns section immediately before File Organization.

Summary

Adds a new Patterns rule recommending CIFilter's typed factory methods (from CIFilterBuiltins) over the string-based CIFilter(name:) initializer and KVO setValue(_:forKey:).

No SwiftLint or SwiftFormat rule exists for this — it is a style guide entry only.

Reasoning

CIFilter(name:) returns an optional and requires stringly-typed KVO for parameter access. The CIFilterBuiltins factory methods (available since iOS 14) provide non-optional returns and compile-time type-checked properties, eliminating an entire class of runtime errors.

The typed API requires import CoreImage.CIFilterBuiltins, which is an unusual submodule import but is Apple's documented approach.

Reference: https://developer.apple.com/documentation/coreimage/processing-an-image-using-built-in-filters

Prefer CIFilter typed factory methods (CIFilterBuiltins) over string-based
CIFilter(name:) and setValue(_:forKey:). Adds rule entry to the Patterns
section immediately before File Organization.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant