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
SwiftLint provides a rule to enforce the use of literals over UIImage and UIColor initializer, but while object_literal makes sense for some projects and users, it doesn't for others.
Some of the reasons not to use literals:
Icons and colors (but specially icons) can be really hard to identify
because they're teeny-tiny rendered, and/or
against dark background of some Xcode color schemes
When reading the code, it's hard to know which color or image is being used. There's no context, no asset or color name, no immediate information about it.
To learn more about the color or image being used, one has to stop reading the code and browse through additional code to find more about these.
etc...
Below, the same image literal example with four different Xcode templates.
Default:
Civic:
Nord:
Ayu 2:
As shown above, the icon is hard to visualize when using dark background color and there's no information about the asset used (which asset is being used?, what's its name?).
A custom rule can be used as workaround to disable image literals while the new opt-in rule isn't implemented and merged into master.
SwiftLint provides a rule to enforce the use of literals over
UIImage
andUIColor
initializer, but whileobject_literal
makes sense for some projects and users, it doesn't for others.Some of the reasons not to use literals:
Below, the same image literal example with four different Xcode templates.
Default:
Civic:
Nord:
Ayu 2:
As shown above, the icon is hard to visualize when using dark background color and there's no information about the asset used (which asset is being used?, what's its name?).
A custom rule can be used as workaround to disable image literals while the new opt-in rule isn't implemented and merged into master.
A similar custom rule can be easily implemented for color literals.
The text was updated successfully, but these errors were encountered: