You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduced in Xcode 15, Apple now provides type-safe access to Color and Image assets. This is done with a compile-time extension providing properties for all available assets. These can be access using new initialisers on Color and Image types (in UIKit, SwiftUI, and AppKit).
Given the enhancements this provides to safety (ensuring codebases only reference resources which actually exist), I think it would be a good rule to have in most codebases to use these new extensions -- thus having it available in this tool would be beneficial.
This rule becomes slightly more complicated when you take into account non-static strings (where the named value is either a variable, or a string containing an interpolated variable).
// Non TriggeringUIImage("flag/\(countryCode)")letsomeStringFromViewModel= model.imageName
Color(someStringFromViewModel)// TriggeringColor(isDarkMode ? "textDark":"textLight")
Logic
It's worth noting the property name generated by Xcode is not 100% the same as the asset name (used in the named variable). Some known examples:
Camel Case: some_blue = someBlue
Trim Color from End: someBlueColor = someBlue
The text was updated successfully, but these errors were encountered:
Description
Introduced in Xcode 15, Apple now provides type-safe access to Color and Image assets. This is done with a compile-time extension providing properties for all available assets. These can be access using new initialisers on Color and Image types (in UIKit, SwiftUI, and AppKit).
Given the enhancements this provides to safety (ensuring codebases only reference resources which actually exist), I think it would be a good rule to have in most codebases to use these new extensions -- thus having it available in this tool would be beneficial.
Examples
Non Triggering Examples
This rule becomes slightly more complicated when you take into account non-static strings (where the named value is either a variable, or a string containing an interpolated variable).
Logic
It's worth noting the property name generated by Xcode is not 100% the same as the asset name (used in the named variable). Some known examples:
some_blue
=someBlue
someBlueColor
=someBlue
The text was updated successfully, but these errors were encountered: