All Projects → metasmile → robjc

metasmile / robjc

Licence: other
An objc class generator which does map physical directory structure of the project resource into member properties of a class. Inspired from android.R

Programming Languages

python
139335 projects - #7 most used programming language

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}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].