-
Notifications
You must be signed in to change notification settings - Fork 395
Using mogenerator
Tom Harrington edited this page Apr 20, 2019
·
2 revisions
mogenerator
is a command-line tool which generally requires a few arguments to produce useful results. In most cases your mogenerator
command will be something like
mogenerator --model [PATH TO MODEL] --output-dir [OUTPUT PATH]
Swift users would also want to add --swift
:
mogenerator --swift --model [PATH TO MODEL] --output-dir [OUTPUT PATH]
However there are many other possibilties.
Argument | Description |
---|---|
--model PATH, -m PATH |
Path to the model file. If the path is for a .xcdatamodeld directory, mogenerator uses the current version of the model as configured in Xcode. You can use the path to a .xcdatamodel to force mogenerator to use a specific model version. |
--output-dir DIR, -O DIR |
Location to use for generated files. If either --machine-dir or human-dir is used, they take precedence over this argument for the appropriate files. |
--human-dir DIR, -H DIR |
Output directory for machine files, which are regenerated every time mogenerator runs. |
--machine-dir DIR, -M DIR |
Output directory for human files, which are only generated if they don't already exist. |
--swift , -S
|
Generate Swift templates instead of Objective-C. Without this, Ojbective-C is assumed |
--configuration CONFIG, -C CONFIG |
Only consider entities included in the named configuration. With this argument mogenerator looks in the model file for a specific configuration and ignores any entities that aren't part of that configuration. |
--base-class CLASS |
Custom base class. By default, generated classes inherit from NSManagedObject . Use this argument to inherit from a different class. |
--base-class-import TEXT |
Imports base class as #import TEXT (Objective-C) or import TEXT (Swift) for all generated files. |
--base-class-force CLASS |
Same as --base-class except will force all entities to have the specified base class. Even if a super entity exists. |
--includem PATH |
Generate aggregate include file for .m files for both human and machine generated source files. PATH should be the full path to a file which will contain #import statements for every generated .m file. This argument has no effect if --swift is used. |
--includeh PATH |
Generate aggregate include file for .h files for human generated source files only. PATH should be the full path to a file which will contain #import statements for every generated .h class. This argument has no effect if --swift is used. |
--template-path PATH |
Path to custom template files (absolute or relative to model path). Not necessary unless you are using custom templates. |
--template-group NAME |
Name of template group. This argument causes mogenerator to search the Application Support directory for a folder with the specified name and to look for template files there. If template-path is used, this argument is ignored. |
--template-var KEY=VALUE |
A key-value pair to pass to the template file. This may be used more than once. Consult template files for possible keys and acceptable values. |
--list-source-files |
List files that would be generated but don't generate the files. |
--orphaned |
Only list files whose entities no longer exist. |
--v2 , -2
|
No effect. |
--version |
Display mogenerator version and exit |
--help , -h (or no arguments) |
Print help, including a list of possible arguments. |
Older versions of mogenerator
included an Xcode extension to generate code called "Xmo'd". This was based on an old Xcode extension system that stopped working several years ago.