• Stars
    star
    506
  • Rank 87,236 (Top 2 %)
  • Language
    Ruby
  • License
    MIT License
  • Created almost 11 years ago
  • Updated almost 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A lint tool for UIStoryboard to find wrong classes and wrong storyboard/segue/reuse identifiers

StoryboardLint

Build Status

A lint tool for UIStoryboard to find wrong classes and wrong storyboard/segue/reuse identifiers.

Background

In iOS development, UIStoryboards are a pain to use for many reasons. Two big reasons are:

  • You can only use string literals as identifiers for view controllers and segues in your Storyboards. You need those same string literals again in your source code when referencing anything in your Storyboard: So you have your IDs in two or more places and no way to know if the IDs you use in your code actually exist in your Storyboard.
  • You have no way of knowing whether your Storyboard references classes in your source code that don't exist (anymore).

Fear Not!

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:

  • Makes sure your UITableViewCell and UICollectionViewCell reuse identifiers are named according to either your own or StoryboardLint's default naming convention.
  • Makes sure your Storyboard and Segue identifiers are named according to either your own or StoryboardLint's naming convention.
  • Makes sure that all custom classes that are references from your Storyboard actually exist is your code.
  • Makes sure that all string literals in your code that reference reuse identifiers, Storyboard identifiers and Segue identifiers (according to a given or default naming convention) actually exist in your Storyboard(s).
  • Produces output that is parsable by Xcode so you can easily plug StoryboardLint into your build process:

Warnings right in your source code:

Xcode Warnings

Warnings about bugs in your Storyboard:

Xcode Warnings

Naming Convention

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:

  • Reuse Identifiers start with ruid_. Example: ruid_ProductTableViewCell.
  • Storyboard Identifiers start with sb_. Example: sb_ProductsViewController.
  • Segue Identifiers start with 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 MyGreatSuffix

The 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.

Installation

Just install the Ruby Gem:

sudo gem install storyboardlint

In your Xcode Project, simply add a "Run Script" build phase in order to run StoryboardLint every time you build:

  1. Go to your project and select your project's target in the "Targets" section.
  2. Go to "Build Phases"
  3. Select from the Menu "Editor -> Add Build Phase -> Add Run Script Build Phase"
  4. Paste this command into the Run Script section: 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
  5. That's it!

More Repositories

1

WWDC-Downloader

Script to download the sample code for all WWDC 2018 sessions.
Ruby
893
star
2

VertexHelper

Lets you graphically define vertices of sprites for Box2D and Chipmunk bodies/shapes.
Objective-C
243
star
3

AddressBookSpy

A demo app showcasing the use of JavaScriptCore in an iOS app
C
132
star
4

Raphuccino

A Cappuccino & Objective-J wrapper for the awesome RaphaelJS vector graphics library
Objective-J
70
star
5

rubymotion_autolayout

A very basic RubyMotion ASCII DSL to create views
Ruby
38
star
6

MapKit

A Google Maps API abstraction layer written for Cappuccino
Objective-J
34
star
7

SproutCoreNative

Experiments in running SproutCore on iOS with JavaScriptCore without a WebView
JavaScript
32
star
8

private-dumper

A Ruby class-dump wrapper to create header files from private iOS frameworks
Ruby
23
star
9

code_buddy

A Meteor.js app that lets you share live code snippets across multiple browsers. With syntax highlighting.
JavaScript
22
star
10

CPVideoKit

Cappuccino & Objective-J wrapper for the YouTube and Vimeo JavaScript API
Objective-J
22
star
11

CPOperation

Cappuccino implementation of NSOperation, NSOperationQueue, NSInvocationOperation and NSBlockOperation
Objective-J
15
star
12

CappuccinoLocations1

A cappuccino sample project with Google Maps integration
Objective-J
13
star
13

iphonedevcon2010-sproutcore-demo

An iPad SproutCore Touch demo for my talk at the iPhone Developer Conference 2010
Objective-J
12
star
14

MacRubyRemote

Remote control your Cocoa app with a Cappuccino web interface. Poke around.
Objective-J
12
star
15

MapKit-HelloWorld

The simplest possible MapKit application
Objective-J
11
star
16

Xcode4templates

Tool to extract Xcode 4 application templates and convert them to be used with Xcode 5 to get options like "Use Storyboards" back.
Ruby
10
star
17

ObjjSafariExtension

A proof of concept that you can write Safari Extensions using Objective-J and Cappuccino
Objective-J
8
star
18

DictationSwitcher

A small tool for OS X 10.8 Mountain Lion to switch the dictation language with one click
Objective-C
7
star
19

ViewControllerDemo

A demo application showcasing the usage of iPhone view controllers
Objective-C
7
star
20

xcode-languages

All the lproj languages that Xcode supports in a machine readable format.
Swift
7
star
21

CPVideoKitDemo

Demo of the Cappuccino VideoKit
Objective-J
6
star
22

Born-To-Be-Alive

Patrick Hernandez hit performed by Alex, the NSSpeechSynthesizer's best voice.
Objective-C
6
star
23

SPWKAspectFitView

A demo for http://stackoverflow.com/a/26066314/171933
Objective-C
6
star
24

sproutcore-raphael

A demo app that shows how to use Raphael.js in a SproutCore 2.0 app
JavaScript
6
star
25

plswift-2023-demos

Demos for my plSwift 2023 talk "Living dangerously: The why and how of safely using private APIs on iOS"
Swift
5
star
26

turbo-derive

Easily handle derived Core Data properties in a pain free, KVO-compliant way
Objective-C
5
star
27

deutsche-bank-csv-converter

Converts CSV bank balance reports from Deutsche Bank to a format FreeAgentCentral.com can use
Ruby
5
star
28

CappuccinoCibImageSearch

Cappuccino Cib-based Google Image Search Client with CPTableView goodness
Objective-J
4
star
29

MacDevImageSearch

SproutCore Image Search project for an article in Mac Developer.
JavaScript
4
star
30

fahrenkrug-s-hash

A sample app that demonstrates how Apple's NSURL HTTP authentication caching is buggy. And the workaround.
4
star
31

sc-template-image-search

JSConf.it 2011 SproutCore Demo
JavaScript
3
star
32

MacRubyLyrics

Search for lyrics and have them read to you with MacRuby, JavaScript, and Cocoa
Ruby
3
star
33

radiant-xapian-search-extension

Adds Xapian support to Radiant pages
Ruby
3
star
34

iPhone-Webtech

Files for my iPhone View Controllers session at WebTech 09
Objective-C
3
star
35

nsspain-2022-demos

Swift
2
star
36

KVOMemoryLeak

Demonstrates a memory leak in KVO on iOS when incorrectly overriding didChangeValueForKey:
2
star
37

XcodeTemplates

Custom Xcode Templates for fun and profit.
2
star
38

QuartzPatternBugDemo

Quartz Patterns in NSViews only get drawn with wantsLayer=YES. Bug?
Objective-C
2
star
39

Radiant-Performance-Decline

two test projects showcasing a significant performance decline from Radiant 0.8.1 to 0.9.1
JavaScript
2
star
40

jfahrenkrug.github.com

My Blog and Website
JavaScript
2
star
41

CPCollectionViewBugDemo

Demonstrates a selection bug in Cappuccino's CPCollectionView
Objective-J
2
star
42

layer0-nextjs-example

JavaScript
1
star
43

AFNetworkingPerformanceTest

App to demonstrate how UI performance is impacted by AFNetworking downloads
Objective-C
1
star
44

UITabBarControllerMoreBugWorkaround

Workaround for a bug in UITabBarController
Objective-C
1
star
45

abv-calculator-action

A GitHub Action to calculate ABV given the original and final gravity of a beverage. No, it's not very useful.
JavaScript
1
star