Enhance the development experience with CoreData by providing greater type-safety and intuitive functionality
🕹️ Take full control of your CoreData management.
🧑💻 100% managed code, no code generation required.
📖 Free from Xcode GUI, and human-friendly diff records on git.
Make sure you've declared Crush
as your dependency before getting started
let package = Package(
dependencies: [
.package(
url: "https://github.com/ezoushen/Crush",
from: "TARGET_VERSION"
),
],
targets: [
.target(
name: "<your-target-name>",
dependencies: [
"Crush"
]
)
]
)
Only three steps to start using Crush
1. Define your schema
class Todo: Entity {
@Required
var title = Value.String("title") // A required string property named "title"
@Optional
var memo = Value.String("memo") // An optional string property named "memo"
@Required
@Default(false)
var finished = Value.Bool("finished")
@Optional
var parent = Relation.ToOne<Todo>("parent") // An optional relationship to another Todo
@Optional
@Inverse(\.parent)
var children = Relation.ToMany<Todo>("children")
}
2. Create your DataContainer
let container = try DataContainer.load(
storages: .sqlite(url: targetURL),
dataModel: DataModel(name: "V1", [ Todo() ]))
3. Start coding 🔥🔥🔥
try container.startSession().sync { context in
let todo = context.create(Todo.self)
todo.title = "Hello Crush"
try context.commit()
}
Swift DocC style documentation is available here
If you want to contribute to the project, please feel free to open a pull request/issue.