Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cypherpoet/coredatakit
A collection of utilities for building Core Data applications in SwiftUI.
https://github.com/cypherpoet/coredatakit
coredata coredata-swiftui swift-packages swiftui xcode
Last synced: 1 day ago
JSON representation
A collection of utilities for building Core Data applications in SwiftUI.
- Host: GitHub
- URL: https://github.com/cypherpoet/coredatakit
- Owner: CypherPoet
- License: mit
- Created: 2019-11-23T07:04:38.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-09-18T21:14:50.000Z (about 3 years ago)
- Last Synced: 2023-03-02T17:41:27.351Z (over 1 year ago)
- Topics: coredata, coredata-swiftui, swift-packages, swiftui, xcode
- Language: Swift
- Homepage: https://cypherpoet.github.io/CypherPoetCoreDataKit/
- Size: 815 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# CoreData Kit
_A collection of utilities for building Core Data-backed applications in Swift._
## 🚧 Disclaimer
This library is still very much a WIP as I study/experiment with/develop best practices, patterns, and affordances for Core Data after the releases of Swift 5.5 and "SwiftUI 3.0". Please treat it as a guideline/reference for the time being 🙂.
## Features
- ✅ A [`CoreDataManager`](./Sources/CoreDataManager/) that handles setting up a ["Core Data Stack"](https://developer.apple.com/documentation/coredata/core_data_stack).
- ✅ A [`rich set of utilities`](./Sources/Migration/) for performing Core Data migrations.
- ✅ A [`FetchedResultsControlling` protocol](./Sources/FetchUtils/FetchedResultsControlling.swift) that helps architect `NSFetchedResultsController` instances and extract data from their `NSFetchRequest` results.
- ✅ Utilities for composing `NSPredicate` instances in a strongly-typed fashion.
- ✅ Strongly-typed errors under types like `CoreDataManager`, `PersistentStoreMigrator` and more.
- ✅ `NSPersistentStore` helpers for using different SQLite writing locations in development and production.## Installation
### Xcode Projects
Select `File` -> `Swift Packages` -> `Add Package Dependency` and enter `https://github.com/CypherPoet/CypherPoetCoreDataKit`.
### Swift Package Manager Projects
You can add this project as a package dependency in your `Package.swift` file:
```swift
let package = Package(
//...
dependencies: [
.package(
url: "https://github.com/CypherPoet/CoreDataKit",
.exact("0.0.21")
),
],
//...
)
```From there, refer to the `CoreDataKit` "product" delivered by the `CypherPoetCoreDataKit` "package" inside of any of your project's target dependencies:
```swift
targets: [
.target(
name: "YourLibrary",
dependencies: [
.product(name: "CoreDataKit", package: "CypherPoetCoreDataKit"),
],
...
),
...
]
```Then simply `import CoreDataKit` wherever you’d like to use it.
## Usage
Currently, usage of these utilities is best demonstrated by the various example applications [here](./Examples/). But a few pointers...
### Dynamically initializing a Core Data Stack for your app depending on whether it's running for production or for Xcode Previews.
- [🔗 Example](https://github.com/CypherPoet/CoreDataKit/blob/migration-helpers/Examples/ReviewJournal/Shared/Misc%20Utils/Extensions/CoreDataManager%2BUtils.swift)
### Setting up the Core Data stack on launch
- [🔗 iOS Example](./Examples/ReviewJournal/iOS/App/AppDelegate.swift)
- [🔗 macOS Example](./Examples/ReviewJournal/macOS/App/AppDelegate.swift)### Core Data Migrations
- [🔗 Example application built specifically around this.](./Examples/ReviewJournal)
### Requirements
- Xcode 13.0+ (Recommended)
### 📜 Generating Documentation
Documentation is generated by [Swift Doc](https://github.com/SwiftDocOrg/swift-doc). Installation instructions can be found [here](https://github.com/SwiftDocOrg/swift-doc#installation), and as soon as you have it set up, docs can be generated simply by running `./Scripts/generate-html-docs.zsh` from the command line.
📝 Note that this will only generate a `.build/documentation` folder for you to view locally. This folder is being ignored by `git`, and a GitHub [action](./.github/workflows/PublishDocumentation.yml) exists to automatically generate docs at the root level and serve them on the project's `gh-pages` branch.
## 🏷 License
`CypherPoetCoreDataKit` is available under the MIT license. See the [LICENSE file](./LICENSE) for more info.