Skip to main content
Skip table of contents

Entity Generation (iOS)

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.

The JSON definition files can be exported from Cantara Server. For information about the procedure to generate the export files, refer to Exporting a Function and Exporting a Query.

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

Prerequisites

The entity generation script requires the SwiftGen tool, which can be installed with the command "brew install swiftgen".

  1. Add the generate-entity-files.sh script to the project Scripts folder
  2. Add a run script to the build phases section of your project, defined as follows:

    CODE
    sh ./Scripts/generate-entity-files.sh
  3. Move the run script to the Dependencies build phase
  4. Within the project folder, create a subfolder named SchemaGeneration
  5. Within the SchemaGeneration folder, create two sub-folders named Definitions and Templates
  6. Within the Definitions folder, add the JSON definition files for your project
  7. Under the Templates folder, add the stencil templates files
  8. Build the project: the generated files will be created in the target folder, under Source/Schema.



  9. 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.




JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.