How do the Mogenerator options that I can send via Xcode work?

Help for the Mogenerator is very minimal. What do all options do?

+62
documentation mogenerator
Aug 28 2018-10-10T00:
source share
4 answers

Parameters that work both with the command line utility and with Xcode:

  • --base-class : name af in the base class that inherits the "private class" (for example, _MyObject.h ). This will also add the import in the form of #import "MyManagedObject.h" to the same .h file. Tip. If the class you want to inherit is in the library, the default import statement will not work. As a workaround, you can get an additional level of inheritance for each project you create and inherit this class from the library (for example, set the base class in MyProjectManagedObject , which you create manually and inherit from MyLibManagedObject ).
  • --template-path : path to file 4 .motemplate . When this is not provided, it will look at all the "application support directories" (for example, "/Library/Application Support/mogenerator/" ).
  • --template-group : the name of the subdirectory under the template-path directory used.
  • --template-var arc=true : Required for generated compilation files when using ARC.
  • --output-dir : output directory for all generated files.
  • --machine-dir : the directory into which the _<class>.h and _<class>.m lines will be output. If --output-dir is also specified, this option takes precedence.
  • --human-dir : the directory into which the values โ€‹โ€‹of <class>.h and <class>.m will be displayed. If --output-dir is also specified, this option takes precedence.
  • --includem : the full path to the file that will contain all #import for all generated .h files. This file should not exist (i.e. it will be created for you if it is not). This file will not be automatically included in the project. You must enable it manually by dragging it to the "Groups and Files" list of your project.

Using relative paths in Xcode for any of the above arguments will not work, since the working directory is installed in one of the root directories of the system (for example, applications, developer, library or system). (I did not have enough time to figure out which one is for sure.)

Parameters that cannot be used in Xcode:

  • --model : the path to the .xcdatamodel file cannot be set in Xcode.
  • --list-source-files
  • --orphaned
  • --versioned
  • --help

Running and sending parameters to xmod via Xcode:

(Update: I have not tried this on Xcode 4, only Xcode 3. For Xcode 4, you can add mogenerator as the build phase instead of the following steps.)

  • Go to the information page of the .xcdatamodel file.
  • Select the Comments tab.
  • Add xmod to the comment field in your line.
  • Each time you save a model, it restores the machine files for you.

To send parameters, they must be on a separate line:

It works:

 xmod --base-class CLASS --template-path PATH 

And even this works:

 xmod --base-class CLASS --template-path PATH 

But this will not work:

 xmod --base-class CLASS --template-path PATH 

Note. You must close the "Information" window for the settings to take effect.

+141
Aug 28 '10 at 2:50
source share

Starting with Xcode 4, the Info window is no longer available, so donโ€™t worry if you canโ€™t configure it, as mentioned above.

Use the John Blanco guide to set up a target script that allows you to pass command line arguments directly to movenerator. Please note that you may need to slightly change the paths in his example ... load pwd into a script and check the paths to the script working directory if it does not start for you right away.

For a list of available command line arguments, run mogenerator --help in a terminal. AFAICT, they all work from the scripting stage.

See this answer for another way to call mogenerator through a โ€œpre-actionโ€ if you want to automatically rebuild your machine files with each assembly. There's also some good advice on installing a mogenerator script in your VCS.

+6
Feb 15 '13 at 23:27
source share

Here is the result from --help from version 1.27

 mogenerator: Usage [OPTIONS] <argument> [...] -m, --model MODEL Path to model -C, --configuration CONFIG Only consider entities included in the named configuration --base-class CLASS Custom base class --base-class-import TEXT Imports base class as #import TEXT --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 FILE Generate aggregate include file for .m files for both human and machine generated source files --includeh FILE Generate aggregate include file for .h files for human generated source files only --template-path PATH Path to templates (absolute or relative to model path) --template-group NAME Name of template group --template-var KEY=VALUE A key-value pair to pass to the template file. There can be many of these. -O, --output-dir DIR Output directory -M, --machine-dir DIR Output directory for machine files -H, --human-dir DIR Output directory for human files --list-source-files Only list model-related source files --orphaned Only list files whose entities no longer exist --version Display version and exit -h, --help Display this help and exit Implements generation gap codegen pattern for Core Data. Inspired by eogenerator. 
+1
Aug 22 '13 at 17:58
source share

It may also be useful. To determine which options you can use to

 --template-var KEY=VALUE 

open the * .motemplate file and find a line like "TemplateVar". after the dot you will see the parameter name and you can understand what it does.

This option has a built-in template.

 --template-var arc=true --template-var frc=true --template-var modules=true 
0
Jun 29 '14 at 2:52
source share



All Articles