Code Monkey home page Code Monkey logo

gyro's Introduction

Gyro

gem version build circle ci Twitter

Gyro is a tool to generate Realm model classes, for both Android (Java) and iOS/macOS (Swift), from an .xcdatamodel file.


G enerate
Y our
R ealm
O bjects

Introduction

The .xcdatamodel file is usually used to represent Core Data entities in Xcode in a graphical way. It can be created or edited with a graphical user interface in Xcode.

But with Gyro, you will now be able to use an xcdatamodel to create a Realm model files as well!

This will allow you to design your model in a visual way (rather than by code), only once (rather than once for Android and once for iOS), and have the code generated for you.

Simple Entity

The .xcdatamodel file is the input of the script.

Installation

Gyro is on RubyGems, so this means you can simply install it by using this command in your terminal:

gem install gyro

Alternativly, you could also clone this repository anywhere you want on your machine, then build and install the local gem

gem build gyro.gemspec
gem install gyro-1.0.0.gem

Usage

Invoke it with the appropriate options like this:

gyro --model <model> --template <template-name> --output <output-dir> --param <key>:<value>

<model> is the path to the xcdatamodel file

<output-dir> is the path to the output directory file

<template-name> is the name of the template. Below you have the list of templates.

If you want additional information about templates you can go to the documentation for each :

Annotating your xcdatamodel

The .xcdatamodel Xcode editor allows you to add "user infos" to your entities, attributes or relationships. Each "user info" entry is an arbitrary key/value pair.

To define a User Info key in Xcode's xcdatamodel editor, select the entity or attribute you want to add a User Info to, then select the 3rd tab in the inspector on the right ("Data Model Inspector", or Cmd-Alt-3), and fill the information you want in the "User Info" section there.

enum_json

With the help of these "user infos", you will be able to give Gyro extra information about your model classes. For example, you can tell which attribute is the primary key, the attributes to ignore, the JSON mappings, โ€ฆ

For more information about "user infos", you can see the dedicated documentation here.

License

This tool is under the Apache 2 License.

It has been initially developed by Niji and is in no way affiliated to the Realm company.

gyro's People

Contributors

alisoftware avatar stevenwatremez avatar tomtom-fr avatar abretagne-axt avatar colasbd avatar bmarty avatar hrougier avatar

Watchers

James Cloos avatar  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.