Skip to content

scaffold_coredata_model

Generate a Core Data model (.xcdatamodeld) file with a named entity and optionally pre-defined attributes. This tool creates the data model file that Core Data uses to define your persistent object graph, saving you from manually configuring entities in the Xcode model editor.

ParameterTypeRequiredDefaultDescription
namestringYesThe name of the Core Data entity (e.g., "Workout")
outputPathstringYesAbsolute path to the directory where the .xcdatamodeld package will be created
attributesarrayNoList of attribute objects, each with name (string) and type (enum)

The type field in each attribute object accepts one of the following values:

String, Integer16, Integer32, Integer64, Double, Float, Boolean, Date, Binary, UUID, URI

“Create a Core Data model for a Workout entity with name, duration, calories, and date”

{
"name": "Workout",
"outputPath": "/Users/dev/Projects/FitnessTracker/FitnessTracker/Models",
"attributes": [
{ "name": "name", "type": "String" },
{ "name": "duration", "type": "Double" },
{ "name": "caloriesBurned", "type": "Integer32" },
{ "name": "completedAt", "type": "Date" },
{ "name": "id", "type": "UUID" }
]
}

“Scaffold a Core Data model called MealEntry that I’ll configure later”

{
"name": "MealEntry",
"outputPath": "/Users/dev/Projects/FitnessTracker/FitnessTracker/Models"
}

Create an entity with binary data for images

Section titled “Create an entity with binary data for images”

“Create a Core Data model for UserProfile that stores an avatar image”

{
"name": "UserProfile",
"outputPath": "/Users/dev/Projects/FitnessTracker/FitnessTracker/Models",
"attributes": [
{ "name": "id", "type": "UUID" },
{ "name": "displayName", "type": "String" },
{ "name": "email", "type": "String" },
{ "name": "avatarData", "type": "Binary" },
{ "name": "joinedAt", "type": "Date" },
{ "name": "isPremium", "type": "Boolean" }
]
}
Created Core Data model: /Users/dev/Projects/FitnessTracker/FitnessTracker/Models/Workout.xcdatamodeld
Entity: Workout
Attributes:
name String
duration Double
caloriesBurned Integer32
completedAt Date
id UUID
  • scaffold_viewmodel — Create a view model that fetches and manages Core Data objects
  • scaffold_view — Generate a SwiftUI view to display Core Data entities
  • project_create — Create a new project that can include Core Data support