Giter Club home page Giter Club logo

robjc's Introduction

R_objc

Objective-C resource class generator which can be mapped physical dir structure into member properties of a class. Inspired by android.R

usage

$ robjc ~/Documents/myproj/resources
usage: robjc.py [-h] [-c [CLASS_NAME]] [-m [MAP_DIR_STRUCTURE]]
                [-a [ALIAS_ENABLED]] [-l [SHOW_LOG]]
                [<target path>] [<destination path>]

Objective-c resource class generator

positional arguments:
  <target path>         Target path to read directories. (default=./)
  <destination path>    Destination path to create a class file. (default=./)

optional arguments:
  -h, --help            show this help message and exit
  -c [CLASS_NAME], --class-name [CLASS_NAME]
                        Class name. (default=R)
  -m [MAP_DIR_STRUCTURE], --map-dir-structure [MAP_DIR_STRUCTURE]
                        Map structure of all directories from target path.
                        (default=False)
  -a [ALIAS_ENABLED], --alias-enabled [ALIAS_ENABLED]
                        Enabling symbolic alias. (default=False)
  -l [SHOW_LOG], --show-log [SHOW_LOG]
                        Show log. (default=False)

It generates

R.h
R.m

and then, You can use it like below after import.

R.image_name

Mapping dir structure

You can write same directory structure via target path.

/Users/user/Documents/myproj/resources/image1.png
~/Documents/myproj/resources/image2.png
~/Documents/myproj/resources/sounds/sound1.caf
~/Documents/myproj/resources/sounds/sound2.caf
~/Documents/myproj/resources/sounds/ui/sound3.caf

add a option '-m'.

$ robjc -m ~/Documents/myproj/resources

result:

R.image1
R.image2
R.sounds.sound1
R.sounds.sound2
R.sounds.ui.sound3

Make a symbolic alias

This feature is very useful when you assign the uses of each image to the physical file which contains same content.

use_for_caseA.svg
use_for_caseB.svg
blabla.svg

BUT 3 files are perfectly same image... Perhaps you want to use a single file.

In that case, change the file name, as shown below.

use_for_caseA=use_for_caseB=blabla.svg

add a option '-a'.

$ robjc -a ~/Documents/myproj/resources

result :

+ (NSString *)use_for_caseA; {
    return @"use_for_caseA=use_for_caseB=blabla.svg";
}

+ (NSString *)use_for_caseB; {
    return @"use_for_caseA=use_for_caseB=blabla.svg";
}

+ (NSString *)blabla; {
    return @"use_for_caseA=use_for_caseB=blabla.svg";
}

so you can use like below

R.use_for_caseA
R.use_for_caseB
R.blabla

TODO

  • Support On-Demand Resources
  • Support version of Swift
  • Integration with Termini
  • Automatically import Xcode project with asset files
  • Support symbolic alias [(1) file - (n) method]
  • Support Xcode's i18n policy
  • Generate a util category for taking UIImage or SVGKImage.
  • ex) R.image_name.image / [[R.image_name] imageAsSVG:(CGSize)size]
  • Support DIR structure mapping
  • Add a feature to validate file of resource.(initialize-time checking)
  • Support css's @media query-like filtering, sorting, mapping feature.(e.g. R.png.{only png files}, R.xib.{only xib files}

robjc's People

Contributors

metasmile avatar

Stargazers

 avatar  avatar Alessandro Aresta avatar Xie Wu avatar Roman avatar  avatar Sangwon Kim avatar Jichao Wu avatar Semyon Belokovsky avatar Carabineiro avatar  avatar

Watchers

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