The CC6 SDK includes a script which generates the Domain and ManagedObject classes for each entity in your project, and also generates the Core Data model. The script takes its input from JSON-formatted definitions files. An example file is shown below.
After export, the JSON definition files for entity generation can be modified by the developer.
For information about the file format, refer to JSON Definition Files for Entity Generation.
To run the entity generation script
The entity generation script requires the SwiftGen tool, which can be installed with the command "brew install swiftgen".
- Add the generate-entity-files.sh script to the project Scripts folder
Add a run script to the build phases section of your project, defined as follows:CODE
- Move the run script to the Dependencies build phase
- Within the project folder, create a subfolder named SchemaGeneration
- Within the SchemaGeneration folder, create two sub-folders named Definitions and Templates
- Within the Definitions folder, add the JSON definition files for your project
- Under the Templates folder, add the stencil templates files
- Build the project: the generated files will be created in the target folder, under Source/Schema.
- Add the generated files to your project
Editing the generated files
- The generated Domain and ManagedObject files should not be edited, as they will be generated with every build.
- The Domain and ManagedObject Extension files can be edited as required; they will only be generated if non-existent.