Giter VIP home page Giter VIP logo

seguecode's Introduction

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:

  • Storyboard Scene Identifiers
  • Segue Identifiers
  • Table View Cell Prototype Identifiers
  • Collection View Cell Prototype Identifiers

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:

  • -c or --combine - Export the View Controllers combined in one file
  • -p or --projectName NAME - Name to use as project in source file header comment
  • -l or --verbose - Output verbose logging
  • -v or --version - Display seguecode's version
  • -h or --help - Display help

Preparing your Storyboard

To ensure a proper export please make sure:

  • the segue you wish to use has an Identifier

For extra clarity and reduced conflicts please make sure:

  • the source and destination view controllers have Storyboard IDs

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.

seguecode's People

Contributors

yoiang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

seguecode's Issues

I finally got it to work and was so disappointed with the result

Hi,

After lots of messing around I finally got seguecode to work with a runscript build phase
however, I was very disappointed with the result.

My entire project is written in objectiveC and I do not want to start switching to swift right now
The result came in swift, when i expected it to be in objectiveC
can you add a flag or something to get the result in objectiveC ?

your entire help file shows that the generated code is in objective c

and i did not want nor expect it to be in swift :(

how to create a build phase

I wrote this build phase in my project

echo $(${SRCROOT}/../devtools/seguecode.bundle/Contents/MacOS/seguecode -v)

yet it still tells me that it cant find seguecode

Make code generation extensible (see Paw extensions)

Paw is a great REST client which has support for extensions for dynamic values and code generation. It is very powerful and customizable. This tool could make extensions an option by passing the graph of resources extracted from a storyboard to an extension script which can be used to generate output for any purpose. This way Objective-C, Swift and even Xamarin/C# could be supported.

You can see the Paw extensions at the link below.

https://luckymarmot.com/paw/extensions/?utm_campaign=find_extensions_2.2.1&utm_medium=app&utm_content=extensions_menu&utm_source=paw_http_client_app

These extensions are written with JavaScript to make it easier for more people to contribute. Fortunately node is included with Xcode.

find /Applications/Xcode.app/ -name node

/Applications/Xcode.app//Contents/Developer/usr/share/xcs/Node/bin/node --version

It is not a terribly current version of Node but it is a decent version. It may be possible to use the following command to select and run a version of Node whether or not the user has it installed already.

xcrun node --version

cant create binary

How do you create the seguecode binary ?

I tried installing the plugin from alcatraz, and from source code, building the project seguecodePlugin scheme does not create the binary, and building seguecode scheme gives too many errors on my computer. Can you simply upload a binary i can use ?

Usage Help should be clearer

Running the following commands should show usage.

  • seguecode -?
  • seguecode --help

The output would be...

seguecode -o <output folder> <storyboard>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.