README.markdown

mogenerator

mogenerator is a command-line tool that, given an .xcdatamodel file, will generate two classes per entity. The first class, _MyEntity, is intended solely for machine consumption and will be continuously overwritten to stay in sync with your data model. The second class, MyEntity, subclasses _MyEntity, won't ever be overwritten and is a great place to put your custom logic.

[NEW] "Modern" Objective-C and Swift is default. Apple has made it exceptionally difficult to target older versions of OS X and iOS, so we've given up. The grand --v2 experiment, which I loved, has been killed (the option will still be accepted to not break existing scripts but is now a no-op). From now on if you need to target an older OS, use an older mogenerator. Sorry. (Justin Williams)

[NEW] mogenerator project is now using Travis CI. Travis automatically builds and runs mogenerator's test suite on each commit, reporting the results, making it easier+faster to process Pull Requests. (rentzsch)

[NEW] Change of branch philosophy: master used to be the "stable" branch. Now it's the branch we're going to land incoming Pull Requests. Pull Requests will be accepted onto master pretty freely, Travis will help catch breaking changes. I want to reduce latency and friction for folks to help out with mogenerator. Related reading: Drew Crawford's Conduct unbecoming of a hacker. (rentzsch)

[NEW] Specifying --template-var scalarsWhenNonOptional=true will have mogenerator generate only scalar properties for non-optional entity scalar attributes. For example, consider an age attribute. Without this option, mogenerator will generate two properties: @property (…) NSNumber *age and @property (…) uint16_t ageValue. With this option, only @property (…) uint16_t age would be generated, simplifying things since the age attribute can never be nil. (Mr Anonymous)

[FIX] You can specify an entity's module in Xcode's Core Data Model editor. However, when specifying the current module, the entity class name is prefixed with a period, resulting in an invalid class name. This period is now suppressed. (Saul Mora)

[FIX] override and explicitly include xcshareddata in .gitignore and add the default shared schemes. This fixes the problem where xcodebuild would fail with an The project 'mogenerator' does not contain a scheme named 'mogenerator' error until you first opened it in Xcode. (rentzsch)

[NEW] --v2 argument. I wanted to enable ARC by default, but decided to take it a step further (while not breaking existing scripts). The new --v2 argument is basically semantic versioning for tool arguments.

[NEW] Custom scalar types. Specify attributeValueScalarType for the name of the property's custom type and additionalHeaderFileName if you need to bring in an additional header file for compilation. With this, mogenerator supports C-style and JREnum-style enums. (Quentin ARNAULT)

[NEW] mogenerator's standard templates are now bundled into the mogenerator binary itself. This should solve the problem of templates growing out of sync with the intended version of mogenerator (exacerbated by the now-popular homebrew installer). You can still use your own templates with the --template-path and --template-group parameters. issue 79 (Ingvar Nedrebo, rentzsch).

[NEW] New template that dumps a binary .xcdatamodel into a pseudo-ASCII-plist format perfect for diffing. A great way to compare two versions of a data model. (Brian Webster)

[NEW] Attributes and relationships are now sorted for generation. This should eliminate spurious changes to source files when unrelated model entities are changed. After upgrading to 1.23 you probably want to regenerate all your source files without a model change, just to let things settle in before your next real model change. (Nikita Zhuk)

[NEW] Support for generation of PONSOs: Plain Old NSObjects. These are in-memory, typesafe non-CoreData classes generated from your Xcode data models. Generate reams of ObjC classes from a single data model. Supports relationships and basic serialization. See contributed templates/Nikita Zhuk/ponso/README.txt for details. (Nikita Zhuk)

[NEW] Xmo'd: better support for --(machine|human|output)-dir model option path: now they can be full or relative to the model file. Xcode group and file references are no longer deleted/re-added with every save. (John Turnipseed)

[NEW] Xmo'd: --log-command model option. When enabled, Xmo'd will log (to Console.app) the generated+executed mogenerator invocation. Good for automation debugging and also can provide training wheels for using mogenerator directly. (rentzsch)

Couple --orphaned with --model to get a listing of source files that no longer have corresponding entities in the model. The intent is to be able to pipe its output to xargs + git to remove deleted and renamed entities in one command, something like:

IMPORTANT: 1.14 generates code that may be incompatible with clients of 1.13-or-earlier generated code. +newInManagedObjectContext: has been replaced with +insertInManagedObjectContext: and method implementations have been replaced with @dynamic, which don't work so well with overriding (most of these uses can be replaced with Cocoa Bindings). Upgrade only if you have spare cycles to fix-up existing projects.