Skip to content

Support for .xcdatamodeld and code generation #13

Description

@ashalkhakov

There are two projects we can make use of:

  • momdec
  • mogenerator

We can learn from them what is needed to make our CoreData implementation work with Apple's file formats.

CoreData Code Generation

Xcode generates code for Core Data entities through a build-time process that creates NSManagedObject subclasses or extensions based on the Codegen setting in the Data Model Inspector. The generated files are compiled into the project's DerivedData directory rather than appearing in the project navigator, ensuring they stay in sync with the model file.

The generation behavior depends on the specific Codegen option selected for each entity:

  • Class Definition: Xcode automatically generates both the entity class and its properties extension during the build. This is the default for new entities and requires no manual file management, though the generated properties are typically optional regardless of model constraints.
  • Category/Extension: Xcode generates only the properties extension (e.g., Entity+CoreDataProperties.h/m), while the developer must manually create the base class (e.g., Entity+CoreDataClass.h/m). This allows for custom class hierarchies and business logic.
  • Manual/None: Xcode generates no code. The developer must manually create and maintain the NSManagedObject subclass and its properties using Editor > Create NSManagedObject Subclass or by writing the code directly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions