CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

ifacegen 1.0.0

ifacegen 1.0.0

TestsTested
LangLanguage Obj-CObjective C
License BSD
ReleasedLast Release May 2015

Maintained by Evgeny Kamyshanov.



ifacegen 1.0.0

  • By
  • ptiz

What it is

ifacegen is a code generator, it simplifies using of existing REST+JSON APIs from Objective-C code. ifacegen makes native wrappers for remote service calls and JSON dictionaries. Simple IDL used for description of existing protocol. This is a fork from initial repo, that you can find at https://bitbucket.org/ifreefree/ifacegen

What it is not

ifacegen is not a general purpose serialization tool. It's only compiles IDL given and generates special Objective-C classes accordingly.

Requirements

iOS+ARC, Python 2.7

Limitations

  • For ARC only;
  • NSJSONSerialization used in generated code for JSON data creation, so there is intermediate dictionary created before a data writing in a transport;
  • No "date", "enum" etc. in atomic IDL types. Only int32, int64, double, string, bool, raw и rawstr. "raw" will be converted in NSDictionary from JSON dictionary and "rawstr" — in NSDictionary from JSON dictionary encoded in string (like this: "data": "{\"weird\":42,\"str\":\"yes\"}");
  • All fields in IDL struct are treated as optional. No errors are raised if the value does not exist for the field.
  • No readable error messages for parser and generator yet.

Installation

pod 'ifacegen'

Usage

$ python ifacegen.py [-h] [--prefix PREFIX] [-o OUTDIR] I [I ...]
  • h shows help;
  • PREFIX is a string, ObjC namespace prefix that is added to a name of each class to be generated;
  • OUTDIR is a string, path to directory where the generated files to be placed. By default these files will be placed into a "gen-objc" subdirectory of working dir;
  • I [I ...] are IDL file names to be processed.

If you use Cocoapods to install the tool, you may want to add "Run Script" phase to your Build Phases, like this:

python Pods/ifacegen/generator/ifacegen.py <IDL file names> -o <output directory>

Example can be found in the repo. Also see a tutorial in DOC file

ToDo

  • Mandatory fields;
  • Swift code generator;
  • Parser and generator error handling improvement;
  • CoreData support.