Coder Social home page Coder Social logo

motoswift's Introduction

MotoSwift. Managed Objects to Swift.

Generates Swift NSManagedObject subclasses.

Benefits

Why is it better than Xcode generation?

  1. Xcode generates properties ignoring optional flag
  2. Allows to customize generated code with templates
  3. Allows to specify type for transform properties

Why is it better than Mogenerator?

  1. Allows to generate extensions for machine code

Additionally it allows to generate one file for whole model, e.g. you need list of entity names

Installation

  1. Install MotoSwift by downloading MotoSwift.pkg from the latest GitHub release and running it.

  2. From sources.

Clone or download project.

Run make install

If you need all components in one folder run make bundle. Now you can copy whole motoswift folder, and run motoswift/bin/motoswift from any place

Usage

  • motoswift human [OPTIONS] MODEL_PATH - generate human code for your model. Does not write to file, if file already exists

    Options:

    • --template - Path to entity template.
    • --file-mask - The file name mask for entity file, e.g: "{{class}}.swift"
    • --output - The output directory
  • motoswift machine [OPTIONS] MODEL_PATH - generate machine code for your model. Overwrites file every time

    Options:

    • --template - Path to entity template.
    • --file-mask - The file name mask for entity file, e.g: "{{class}}+Properties.swift"
    • --output - The output directory
  • motoswift model [OPTIONS] MODEL_PATH - generate code for your model

    Options:

    • --output - Output file path.
    • --template - Path to model template.

###Examples

  1. Xcode style

motoswift human --template ./Templates/class.stencil --output ./SampleOutput/XCode --file-mask "{{class}}+CoreDataClass.swift" ./Tests/MotoSwiftFrameworkTests/Resources/TypesModel.xcdatamodeld

motoswift machine --template ./Templates/properties.stencil --output ./SampleOutput/XCode --file-mask "{{class}}+CoreDataProperties.swift" ./Tests/MotoSwiftFrameworkTests/Resources/TypesModel.xcdatamodeld

SampleOutput/Xcode

  1. Mogenerator style

motoswift human --template ./Templates/human.stencil --output ./SampleOutput/Human --file-mask "{{class}}.swift" ./Tests/MotoSwiftFrameworkTests/Resources/TypesModel.xcdatamodeld

motoswift machine --template ./Templates/machine.stencil --output ./SampleOutput/Machine --file-mask "_{{class}}.swift" ./Tests/MotoSwiftFrameworkTests/Resources/TypesModel.xcdatamodeld

SampleOutput/Human

SampleOutput/Machine

  1. All entity and field names

motoswift model --template ./Templates/model.stencil --output ./SampleOutput/Model/Model.swift ./Tests/MotoSwiftFrameworkTests/Resources/TypesModel.xcdatamodeld

SampleOutput/Model/Model.swift

Additional documentation

MotoSwift uses Stencil as template language

motoswift's People

Contributors

igor-palaguta avatar

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.