Compiling a Data Model

A data model is a deployment resource. A data model must not only be a project file, it must be associated with the target that uses it. In addition to details of the entities and properties in the model, the model contains information about the diagram—its layout, colors of elements, and so on. This latter information is not needed at runtime. The model file is compiled to remove the extraneous information and make runtime loading of the resource as efficient as possible.

The model compiler, momc, is located in Library/Xcode/Plug-ins/XDCoreDataModel.xdplugin/Contents/Resources/ in the Developer directory. If you want to use it in your own build scripts, its usage is momc source destination, where source is the path of the Core Data model to compile and destination is the path of the output mom file.

The compiler can generate warnings for various model configuration problems (such as unidirectional relationships). You can toggle these warnings by checking the appropriate boxes in the Warnings section of the project Build panel, as shown in Figure 1.

Figure 1  Project build panel showing momc warning flags