Adorkable / seguecode

the missing support tool for building safe UIStoryboard code
MIT License
22 stars 3 forks source link

seguecode

Travis Build Status

seguecode is a support tool to use alongside UIStoryboard development. It provides compile-time safeties around building with UIStoryboards in an effort to create an error free workflow so you can focus on the important things.

This include exposing:

Xcode Plugin

Installation

Alcatraz

AT THE MOMENT ALCATRAZ INSTALLATION IS BROKEN DUE TO ALCATRAZ'S METHOD OF BUILDING AND INSTALLING. UNTIL A COMPATIBLE WRAPPER PROJECT CAN BE REWRITTEN PLEASE USE THE MANUAL INSTALLATION STEPS BELOW.

The easiest way to get and use seguecode is through the wonderful Xcode plugin manager Alcatraz. The seguecode plugin, when enabled for a storyboard, will detect when you save your storyboard and automatically regenerate your seguecode source code.

Manually

  1. Clone the repo
  2. Run git submodule init ; git submodule update
  3. Run pod install
  4. Open seguecode.xcworkspace and build the seguecodePlugin scheme
  5. Close and reopen Xcode

Usage

To enable the seguecode plugin for a storyboard:

  1. Open the storyboard in Xcode
  2. Pull down Xcode's Edit menu and select the seguecode option

Plugin Screenshot

This will generate a file alongside your storyboard called <Storyboard Name>.seguecode.json which contains configuration information you can change to define how the automatic regeneration works.

The seguecode plugin looks for this json file to see if it should be enabled for a particular storyboard file, deleting it, or unchecking the seguecode option in the Edit menu, will disable the automatic regeneration.

Command Line

You can download the latest release

or

You can make your own build:

  1. Clone the repo
  2. Install the appropriate cocoapods with pod install
  3. Build the binary
  4. Place it in your favorite location for easy access.

It is recommended that you include a run of seguecode in your project as a Run Script Build Phase or as an External Build Target.

Exporting

For an accurate list of parameters run seguecode --help or seguecode -h

The most common usage is

seguecode -o OutputFolder/ ExportMe.storyboard

The resulting header and source files will be exported with the same name as your storyboard file. To use them they should be included in your project and your target.

Note: at minimum seguecode expects an output location and at least one storyboard file

Exporting Customization

To further customize your export use the following parameters:

Preparing your Storyboard

To ensure a proper export please make sure:

For extra clarity and reduced conflicts please make sure:

Results

Storyboard Identifier

TODO

Segue Identifier

Your exported header and source files will contain categories with selectors that describe your segue as well as optionally constants that can be used in your view controller ala self.performSegueWithIdentifier(..., sender: ...) call.

The resulting selectors and constants will depend on the segue Identifier and Storyboard IDs you used in your UIStoryboard.

For example, if you give your segue the Identifier MyHead, the source view controller's Storyboard ID Down and the destination view controller's MyToes the results will be:

Easy method calls:

extension MyViewController {
    @IBAction func performDownFromMyHead(sender : AnyObject? = nil)
}    

Easy constants:

extension MyViewController {
    struct Segues {
        static let DownFromMyHead
    }
}

To use the constant directly from your view controller call:

    self.performSegue(MyViewController.Segues.DownFromMyHead, sender: sender)

Table View Cell Prototype Identifiers

TODO

Collection View Cell Prototype Identifiers

TODO

Contributing

seguecode is a new project that will hopefully continue to grow in usefulness. If you have any ideas or suggestions on how it can better serve you please create an issue labeled feature (check to see if the issue exists first please!). Or suggest a pull request!

Thanks

Props to mogenerator for pointing out ddcli. And being a CoreData savior. And the kick in the butt to start seguecode.