The xiblint script will test .xib and .storyboard files for compliance with best practices and team policies.
The linter messages contain the position within the XML files, and if applicable, an Object ID which can be used in conjunction with Xcode's Find in Workspace to jump to the problematic object in the .xib or .storyboard file.
-
accessibility_formatChecks for incorrect use of Lyft extensions
accessibilityFormatandaccessibilitySources. -
accessibility_labels_for_imagesChecks for images with accessibility enabled and no accessibility label. In this case, VoiceOver will announce the image asset's name, which might be unwanted.
-
accessibility_labels_for_image_buttonsChecks for image buttons with no accessibility label. In this case, VoiceOver will announce the image asset's name, which might be unwanted.
-
accessibility_labels_for_text_with_placeholderChecks for text fields and views with a placeholder and no accessibility label. This addresses common confusion about
placeholderTextcoming instead ofaccessibilityLabel. -
autolayout_framesChecks for ambiguous and misplaced views.
-
automation_identifiersMakes sure that interactive views have accessibility identifiers, to support testing through UI Automation.
-
automation_identifiers_for_outlet_labelsChecks for labels with outlets into a view controller that have no accessibility identifiers. Labels with outlets might get dynamic text, and therefore should be accessible to UI testing.
-
enforce_runtime_attributesEnsures a runtime attribute is set to one of the allowed values. Configure
runtime_attributesin a custom rule configuration usingrules_config(see below). Usenullas an option to allow no value. -
enforce_system_propertiesEnsures a property in a system type is set to one of the allowed values. Configure
system_propertiesin a custom rule configuration usingrules_config(see below). Usenullas an option to allow default value. -
named_colorsEnsures all colors are using named colors from an asset catalog. Configure
allowed_colorsto limit the colors to a subset (default is all named colors are allowed),allow_system_colors(default isfalse),allow_clear_color(default isfalse) andignore_alpha(default isfalse) in a custom rule configuration usingrules_config(see below). -
no_trait_variationsEnsures Trait Variations are disabled.
-
simulated_metrics_retina4_0Ensures simulated metrics are for the iPhone SE, which is currently the smallest display profile.
-
no_view_controller_links_to_other_bundlesEnsures there are no links to other storyboards in different bundles.
-
strict_fontsEnsures all font names and sizes are in an allowed set. Configure
allowed_fontswith an array of dictionaries containing anameandsizein a custom rule configuration usingrules_config(see below). -
strict_font_namesEnsures all font namess are in an allowed set. Configure
allowed_fontsandallow_system_fonts(default istrue) in a custom rule configuration usingrules_config(see below). This is a good option ifstrict_fontsis too strict. -
strict_font_sizesEnsures all font sizes are above a minimum font size. Configure
minimum_size(default is0) and/ormaximum_size(default is1000) in a custom rule configuration usingrules_config(see below). This is a good option ifstrict_fontsis too strict. -
unavailable_custom_classesPrevent a list of classes from appearing as custom classes. Configure
custom_classesin a custom rule configuration usingrules_config(see below). This is a mapping of the full name of the class (ModuleName.ClassName) to the suggested replacement. -
unavailable_system_classesEnsures a system type uses a set of custom clases. Configure
system_classesin a custom rule configuration usingrules_config(see below).
For a list of available rules, run xiblint -h.
Place a configuration file named .xiblint.json into the root of your source repository. A sample configuration file would be:
{
"rules": [
"accessibility_format",
"autolayout_frames"
],
"paths": {
"Pods": {
"rules": []
},
"InaccessibleFeature": {
"excluded_rules": [
"accessibility_*"
]
},
"Modules": {
"rules": ["some_rule"],
"rules_config": {
"some_rule": {
"some_rule_specific_option": true
}
}
}
}
}Then simply invoke xiblint in the source repository.
If you find yourself in need of a different structure of the output, there is the --reporter option.
You are able to choose from the default one, raw, or a json one. To switch between them, use the following:
xiblint --reporter json
xiblint --reporter raw
Sometimes you want to lint only a few files and forget about the rest - for instance, when you want to lint only delta changes. For this case you can specify your files after the xiblint command:
xiblint "Project/Base.lproj/LaunchScreen.storyboard" "Project/Base.lproj/Main.storyboard"
If you want to combine paths with the reporter option, don't forget to put the option before listing the paths:
xiblint --reporter json "Project/Base.lproj/LaunchScreen.storyboard" "Project/Base.lproj/Main.storyboard"
Using pip:
pip install xiblint
Manual:
git clone https://github.com/lyft/xiblint.git
cd xiblint && python setup.py install
This project is governed by Lyft's code of conduct. All contributors and participants agree to abide by its terms.
We require a CLA for code contributions, so before we can accept a pull request we need to have a signed CLA. Please visit our CLA service and follow the instructions to sign the CLA.
Use GitHub issue to file bugs or enhancement requests. You may also use GitHub issues to discuss before implementing a change.
Our only method of accepting code changes is through GitHub pull requests.