{"id":13318102,"url":"https://github.com/ksoichiro/rdotm","last_synced_at":"2025-10-08T00:59:53.806Z","repository":{"id":19275124,"uuid":"22511688","full_name":"ksoichiro/rdotm","owner":"ksoichiro","description":"Objective-C resource definition generator like Android app's R.java.","archived":false,"fork":false,"pushed_at":"2014-10-26T02:29:15.000Z","size":956,"stargazers_count":42,"open_issues_count":2,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-26T01:03:22.849Z","etag":null,"topics":["android","cli","code-generation","ios","objective-c"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ksoichiro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-01T13:49:16.000Z","updated_at":"2022-09-29T03:06:24.000Z","dependencies_parsed_at":"2022-09-10T17:31:00.424Z","dependency_job_id":null,"html_url":"https://github.com/ksoichiro/rdotm","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksoichiro%2Frdotm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksoichiro%2Frdotm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksoichiro%2Frdotm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksoichiro%2Frdotm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ksoichiro","download_url":"https://codeload.github.com/ksoichiro/rdotm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248524858,"owners_count":21118616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","cli","code-generation","ios","objective-c"],"created_at":"2024-07-29T18:29:37.943Z","updated_at":"2025-10-08T00:59:48.758Z","avatar_url":"https://github.com/ksoichiro.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rdotm\n\n[![Build Status](https://travis-ci.org/ksoichiro/rdotm.svg?branch=master)](https://travis-ci.org/ksoichiro/rdotm)\n[![Coverage Status](https://img.shields.io/coveralls/ksoichiro/rdotm/master.svg)](https://coveralls.io/r/ksoichiro/rdotm?branch=master)\n\nrdotm(R.m) is the Objective-C resource definition generator like Android app's `R.java`.\n\n[![Demo](testdata/images/demo.gif)](testdata/images/demo.gif)\n\n## Features\n\n### Color reference method generation\n\n#### What is it?\n\nA tool to generate code that makes you possible to access color resources via method:  \n`\u003ccolor name=\"title\"\u003e#FF0099CC\u003c/string\u003e` -\u003e `[R color_title]`\n\nHex color expressions are converted when executing this tool.  \n(Generated colors are written using `[UIColor colorWithRed:green:blue:alpha]`.)\n\nSo if you have a utility method like `[UIColor colorWithHexString]` to convert hex strings on runtime, your app could be a little bit faster.\n\n### Integer reference method generation\n\n#### What is it?\n\nA tool to generate code that makes you possible to access integer resources via method:  \n`\u003cinteger name=\"max_length_name\"\u003e20\u003c/string\u003e` -\u003e `[R integer_max_length_name]`  \n`\u003citem name=\"max_length_name\" type=\"integer\"\u003e20\u003c/string\u003e` -\u003e `[R integer_max_length_name]`\n\n### String reference method generation\n\n#### What is it?\n\nA tool to generate code that makes you possible to access string resources via method:  \n`\u003cstring name=\"something\"\u003eanything\u003c/string\u003e` -\u003e `[R string_something]`\n\n#### Why should I use Android XML format?\n\nBecause you can share resource files with Android app project.\n\n#### Why not NSLocalizedString?\n\nYou can use `Localizable.strings` and `NSLocalizedString`, but it has a problem that even if you have some typos you will not be noticed while compiling them.\n\nFor example, if you define a string like this:\n\n```c\n\"something\" = \"anything\";\n```\n\nthen you can refer this string with the following code:\n\n```objc\n// OK, this will be @\"anything\"\nNSString *s = NSLocalizedString(@\"something\", nil);\n```\n\nbut you may mistype it:\n\n```objc\n// This is typo, but it won't cause any compile errors\nNSString *s = NSLocalizedString(@\"s0mething\", nil);\n```\n\nThis means that you must run the app manually and detect this bug with your eyes, or write some test codes to detect it.\n\n### Drawable reference method generation\n\n#### What is it?\n\nA tool to generate code that makes you possible to access image resources via method:  \n`res/drawable/star@2x.png` -\u003e `[R drawable_star]`\n\nSuffix like `@2x` will be ignored, so `star.png` and `star@2x.png` will be identified as the same images.\n\n## Install\n\nThere are several methods to install rdotm.\n\n### Release binary\n\n[Get the latest release binary](https://github.com/ksoichiro/rdotm/releases/latest) is the easiest way to install it if you don't have golang environment.  \nNote that the latest release may be stable but not always the \"latest\".  \nIf you want to use the truly latest version, install it with `go get` or `gom`.\n\n### Homebrew\n\nFor OS X users, you can install it with [Homebrew](http://brew.sh/).\n\n```sh\n$ brew tap ksoichiro/rdotm\n$ brew install rdotm\n```\n\n### Install as a golang package\n\nIf you want to install it as a global command, try this:\n\n```sh\n$ go get github.com/ksoichiro/rdotm\n```\n\n### Use gom (recommended)\n\nIf you use this tool in a Xcode build process,\nusing [gom](https://github.com/mattn/gom) is the recommended way.  \nWith this tool, you can manage rdotm's version in your VCS.\n\n```sh\n$ go get github.com/mattn/gom\n$ echo \"gom 'github.com/ksoichiro/rdotm'\" \u003e Gomfile\n$ gom install\n$ tree -L 5\n.\n├── Gomfile\n└── _vendor\n    ├── bin\n    │   └── rdotm\n    └── src\n        └── github.com\n            └── ksoichiro\n                └── rdotm\n```\n\nNow you can use rdotm tool like following command:\n\n```sh\n$ PATH=_vendor/bin:$PATH rdotm -res ...\nor\n$ _vendor/bin/rdotm -res ...\n```\n\nSee sample codes in `testdata/xcode` directories for details.\n\n## Usage\n\n### Basic\n\n```sh\n$ rdotm -res /path/to/res -out /path/to/output/dir\n```\n\n`res` directory should be the Android app's resource structure.  \nExample:\n\n```\nres\n├── drawable\n│   ├── star.png\n│   └── star@2x.png\n└── values\n    ├── colors.xml\n    └── strings.xml\n```\n\n### Options\n\n| Option | Default | Description |\n| ------ | ------- | ----------- |\n| `-class` | R | Class name to overwrite default value(R). |\n| `-clean` | false | Clean output directory before execution. |\n| `-localize` | false | Enable localization using `NSLocalizedStringFromTable`. |\n| `-ps` | string_ | Prefix for generated string methods. |\n| `-pi` | integer_ | Prefix for generated integer methods. |\n| `-pc` | color_ | Prefix for generated color methods. |\n| `-pd` | drawable_ | Prefix for generated drawable methods. |\n| `-pia` | array_integer_ | Prefix for generated integer array methods. |\n| `-psa` | array_string_ | Prefix for generated string array methods. |\n| `-types` | string,integer,color,drawable,integer-array,string-array | Types of resources. Separate with commas. |\n\n## Example\n\n### Input file\n\nres/values/strings.xml\n\n```xml\n\u003cresources\u003e\n    \u003cstring name=\"title_top\"\u003eDemo\u003c/string\u003e\n    \u003cstring name=\"label_message\"\u003eHello, world!\u003c/string\u003e\n\u003c/resources\u003e\n```\n\nres/values/integers.xml\n\n```xml\n\u003cresources\u003e\n    \u003cinteger name=\"sample_number\"\u003e10\u003c/item\u003e\n\u003c/resources\u003e\n```\n\nres/values/colors.xml\n\n```xml\n\u003cresources\u003e\n    \u003ccolor name=\"default_bg\"\u003e#bef\u003c/color\u003e\n    \u003ccolor name=\"default_text\"\u003e#990099cc\u003c/color\u003e\n\u003c/resources\u003e\n```\n\nres/values/arrays.xml\n\n```xml\n\u003cresources\u003e\n    \u003cinteger-array name=\"foobar\"\u003e\n        \u003citem\u003e10\u003c/item\u003e\n        \u003citem\u003e20\u003c/item\u003e\n        \u003citem\u003e30\u003c/item\u003e\n    \u003c/integer-array\u003e\n\n    \u003cstring-array name=\"blurblur\"\u003e\n        \u003citem\u003ehoge\u003c/item\u003e\n        \u003citem\u003efuga\u003c/item\u003e\n        \u003citem\u003epiyo\u003c/item\u003e\n    \u003c/string-array\u003e\n\u003c/resources\u003e\n```\n\nres/drawables\n\n```\nres/drawable\n├── star.png\n└── star@2x.png\n```\n\n### Output file\n\nR.h\n\n```objc\n// DO NOT EDIT.\n// This file is automatically generated by rdotm tool.\n// https://github.com/ksoichiro/rdotm\n\n#import \u003cUIKit/UIKit.h\u003e\n\n@interface R : NSObject\n\n/** Demo */\n+ (NSString *)string_title_top;\n/** Hello, world! */\n+ (NSString *)string_label_message;\n/** 10 */\n+ (NSInteger)integer_sample_number;\n/** #bef */\n+ (UIColor *)color_default_bg;\n/** #990099cc */\n+ (UIColor *)color_default_text;\n+ (UIImage *)drawable_star;\n+ (NSArray *)array_integer_foobar;\n+ (NSArray *)array_string_blurblur;\n\n@end\n```\n\nR.m\n\n```objc\n// DO NOT EDIT.\n// This file is automatically generated by rdotm tool.\n// https://github.com/ksoichiro/rdotm\n\n#import \"R.h\"\n\n@implementation R\n\n+ (NSString *)string_title_top { return @\"Demo\"; }\n+ (NSString *)string_label_message { return @\"Hello, world!\"; }\n+ (NSInteger)integer_sample_number { return 10; }\n+ (UIColor *)color_default_bg { return [UIColor colorWithRed:187/255.0 green:238/255.0 blue:255/255.0 alpha:255/255.0]; }\n+ (UIColor *)color_default_text { return [UIColor colorWithRed:0/255.0 green:153/255.0 blue:204/255.0 alpha:153/255.0]; }\n+ (UIImage *)drawable_star { return [UIImage imageNamed:@\"star\"]; }\n+ (NSArray *)array_integer_foobar { return @[@10, @20, @30]; }\n+ (NSArray *)array_string_blurblur { return @[@\"hoge\", @\"fuga\", @\"piyo\"]; }\n\n@end\n```\n\n#### If the localize option is enabled...\n\nR.m\n\n```objc\n// DO NOT EDIT.\n// This file is automatically generated by rdotm tool.\n// https://github.com/ksoichiro/rdotm\n\n#import \"R.h\"\n\n@implementation R\n\n+ (NSString *)string_title_top { return NSLocalizedStringFromTable(@\"title_top\", @\"R\", nil); }\n+ (NSString *)string_label_message { return NSLocalizedStringFromTable(@\"label_message\", @\"R\", nil); }\n+ (NSInteger)integer_sample_number { return 10; }\n+ (UIColor *)color_default_bg { return [UIColor colorWithRed:187/255.0 green:238/255.0 blue:255/255.0 alpha:255/255.0]; }\n+ (UIColor *)color_default_text { return [UIColor colorWithRed:0/255.0 green:153/255.0 blue:204/255.0 alpha:153/255.0]; }\n+ (UIImage *)drawable_star { return [UIImage imageNamed:@\"star\"]; }\n\n@end\n```\n\nBase.lproj/R.strings\n\n```c\n// DO NOT EDIT.\n// This file is automatically generated by rdotm tool.\n// https://github.com/ksoichiro/rdotm\n\n\"title_top\" = \"Demo\";\n\"label_message\" = \"Hello, world!\";\n```\n\nja.lproj/R.strings\n\n```c\n// DO NOT EDIT.\n// This file is automatically generated by rdotm tool.\n// https://github.com/ksoichiro/rdotm\n\n\"title_top\" = \"デモ\";\n\"label_message\" = \"こんにちは、世界！\";\n```\n\n## License\n\nCopyright (c) 2014 Soichiro Kashima  \nLicensed under MIT license.  \nSee the bundled [LICENSE](https://github.com/ksoichiro/rdotm/blob/master/LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fksoichiro%2Frdotm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fksoichiro%2Frdotm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fksoichiro%2Frdotm/lists"}