Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
helje5 committed Jan 30, 2024
2 parents 2955475 + 4162d58 commit cc4ba2b
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Select latest available Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.0.0'
xcode-version: '15.2.0'
- name: Checkout Repository
uses: actions/checkout@v2
- name: Build Swift Debug Package
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
align="right" width="64" height="64" />
</h2>

**2024-01-19**: Seems to be b0rked w/ Xcode 15.2: Issue https://github.com/Data-swift/ManagedModels/issues/25

> Instead of wrapping CoreData, use it directly :-)
The key thing **ManagedModels** provides is a `@Model` macro,
Expand Down Expand Up @@ -160,6 +162,9 @@ Even just DocC documentation or more tests would be welcome contributions.
- [ManagedModels](https://github.com/Data-swift/ManagedModels/)
- [ManagedToDos.app](https://github.com/Data-swift/ManagedToDosApp)
- Blog article: [`@Model` for CoreData](https://www.alwaysrightinstitute.com/managedmodels/)
- [Northwind for ManagedModels](https://github.com/Northwind-swift/NorthwindManagedModels)
(more complex example, schema with many entities and a prefilled DB for
testing)
- Apple:
- [CoreData](https://developer.apple.com/documentation/coredata)
- [SwiftData](https://developer.apple.com/documentation/swiftdata)
Expand Down
47 changes: 47 additions & 0 deletions Sources/ManagedModels/Documentation.docc/Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,53 @@ struct ToDoListView: View {
- Example ToDo list app: [https://github.com/Data-swift/ManagedToDosApp.git](https://github.com/Data-swift/ManagedToDosApp/)


## Northwind

A little bigger example,
a port of a demo database for SwiftData to ManagedModels:
[Northwind for ManagedModels](https://github.com/Northwind-swift/NorthwindManagedModels)
(SwiftData original:
[NorthwindSwiftData](https://github.com/Northwind-swift/NorthwindSwiftData)).

This is the old [Northwind database](https://github.com/jpwhite3/northwind-SQLite3)
packaged up as a Swift package that works with ManagedModels.
It contains a set of model classes and a prefilled database which makes it ideal
for testing, to get started quickly.

Sample usage
(import `https://github.com/Northwind-swift/NorthwindSwiftData.git`):
```swift
import SwiftUI
import NorthwindSwiftData // @Northwind-swift/NorthwindManagedModels

@main
struct NorthwindApp: App {

var body: some Scene {
WindowGroup {
ContentView()
}
.modelContainer(try! NorthwindStore.modelContainer())
}
}

struct ContentView: View {

@FetchRequest(sort: \.name)
private var products: FetchedResults<Product>

var body: some View {
List {
ForEach(products) { product in
Text(verbatim: product.name)
}
}
}
}
```

- [Northwind for ManagedModels Documentation](https://swiftpackageindex.com/Northwind-swift/NorthwindManagedModels/documentation/northwindswiftdata)


## Topics

Expand Down
3 changes: 2 additions & 1 deletion Sources/ManagedModels/Documentation.docc/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ It is a conversion of the Xcode template project for CoreData.
and press "Add Package" twice.

> At some point Xcode will stop compilation and ask you to confirm that you
> want to use the `@Model` macro provided by ManagedModels.
> want to use the `@Model` macro provided by ManagedModels
> ("Target 'ManagedModelMacros' must be enabled before it can be used.").
> Confirm to continue, or review the source code of the macro first.

Expand Down
3 changes: 3 additions & 0 deletions Sources/ManagedModels/Documentation.docc/Links.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Swift Package URL: `https://github.com/Data-swift/ManagedModels.git`
- [ManagedModels](https://github.com/Data-swift/ManagedModels/)
- filing [GitHub Issues](https://github.com/Data-swift/ManagedModels/issues)
- [Managed ToDos](https://github.com/Data-swift/ManagedToDosApp/) example app
- [Northwind for ManagedModels](https://github.com/Northwind-swift/NorthwindManagedModels)
(more complex example, schema with many entities and a prefilled DB for
testing)


## Apple
Expand Down
2 changes: 1 addition & 1 deletion Sources/ManagedModels/ModelMacroDefinition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public macro Transient() =
* An internal helper macro. Don't use this.
*/
@available(swift 5.9)
@attached(accessor, names: named(init))
@attached(accessor)
public macro _PersistedProperty() =
#externalMacro(module: "ManagedModelMacros", type: "PersistedPropertyMacro")

Expand Down

0 comments on commit cc4ba2b

Please sign in to comment.