一个用于 UIStoryboard 的 lint 工具,可用于查找错误的类以及错误的 storyboard、segue 和重用标识符
一个用于 UIStoryboard 的 lint 工具,可用于查找错误的类以及错误的 storyboard、segue 和重用标识符
A lint tool for UIStoryboard to find wrong classes and wrong storyboard/segue/reuse identifiers.
In iOS development, UIStoryboards are a pain to use for many reasons. Two big reasons are:
With StoryboardLint, you can finally make sure that your code and your Storyboards are in sync (at least to a certain degree). StoryboardLint does the following things:
UITableViewCell and UICollectionViewCell reuse identifiers are named according to either your own or StoryboardLint's default naming convention.Warnings right in your source code:
Warnings about bugs in your Storyboard:
In order for StoryboardLint to find the string literals in your code that contain reuse/Storyboard/Segue identifiers, you need to prefix and/or suffix them in a consistent way. If you don't provide any options, this is the default:
ruid_. Example: ruid_ProductTableViewCell.sb_. Example: sb_ProductsViewController.seg_. Example: seg_ProductDetailsSegue.However, if you already use a certain naming convention or if you would prefer a different one, you can tell StoryboardLint about it using these commandline arguments:
--storyboard-prefix. Example: storyboardlint ~/Code/MyProject --storyboard-prefix MyGreatPrefix--storyboard-suffix. Example: storyboardlint ~/Code/MyProject --storyboard-suffix MyGreatSuffixThe same goes for --segue-prefix, --segue-suffix, --reuse-prefix and --reuse-suffix. You are even allowed to provide both a prefix and a suffix.
Naming your identifiers according to a consistent naming convention should not be too much work and it will be worth it. Ideally you already have string constants for these things in your code, so that you only have to edit two places: your string constant in code and the respective value in your Storyboard.
Just install the Ruby Gem:
sudo gem install storyboardlintIn your Xcode Project, simply add a "Run Script" build phase in order to run StoryboardLint every time you build:
storyboardlint "$SRCROOT" (this will use the default naming convention). Alternatively, you can provide options to tell StoryboardLint about our own naming conventions, for example: storyboardlint "$SRCROOT" --storyboard-suffix Storyboard --segue-suffix Segue --reuse-suffix ReuseID 暂无开放 Issues,或尚未同步最近议题。