From 1be7a4ede1c38ae2684bfa68bd806b2781b34a0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helge=20He=C3=9F?= Date: Tue, 10 Oct 2023 18:24:24 +0200 Subject: [PATCH 1/6] Add specific error message ... --- Sources/ManagedModels/Documentation.docc/GettingStarted.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/ManagedModels/Documentation.docc/GettingStarted.md b/Sources/ManagedModels/Documentation.docc/GettingStarted.md index 5c239be..385dd73 100644 --- a/Sources/ManagedModels/Documentation.docc/GettingStarted.md +++ b/Sources/ManagedModels/Documentation.docc/GettingStarted.md @@ -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. From 478805ab09acf6ca74271ccf0dd3061bf6f3240b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helge=20He=C3=9F?= Date: Sat, 14 Oct 2023 13:11:30 +0200 Subject: [PATCH 2/6] Northwind ... --- README.md | 3 ++ .../Documentation.docc/Documentation.md | 47 +++++++++++++++++++ .../ManagedModels/Documentation.docc/Links.md | 3 ++ 3 files changed, 53 insertions(+) diff --git a/README.md b/README.md index e8d9bad..ea360bb 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,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) diff --git a/Sources/ManagedModels/Documentation.docc/Documentation.md b/Sources/ManagedModels/Documentation.docc/Documentation.md index a1b35ff..0aeca7e 100644 --- a/Sources/ManagedModels/Documentation.docc/Documentation.md +++ b/Sources/ManagedModels/Documentation.docc/Documentation.md @@ -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 + + 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 diff --git a/Sources/ManagedModels/Documentation.docc/Links.md b/Sources/ManagedModels/Documentation.docc/Links.md index a0f71a6..69f7cd3 100644 --- a/Sources/ManagedModels/Documentation.docc/Links.md +++ b/Sources/ManagedModels/Documentation.docc/Links.md @@ -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 From 0263f63780e337109565e8445b462d4b1e40d74b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helge=20He=C3=9F?= Date: Fri, 19 Jan 2024 13:36:44 +0100 Subject: [PATCH 3/6] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ea360bb..1cd8069 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ align="right" width="64" height="64" /> +**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, From b62792d114f6e6bf19c3d37028790033f9660710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Kope=C4=87?= Date: Tue, 30 Jan 2024 17:08:38 +0100 Subject: [PATCH 4/6] Dropped `names:` macro definition of `_PersistedProperty` This fixes an issue with Xcode 15.2 compilation error. --- Sources/ManagedModels/ModelMacroDefinition.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/ManagedModels/ModelMacroDefinition.swift b/Sources/ManagedModels/ModelMacroDefinition.swift index d72f881..77324b5 100644 --- a/Sources/ManagedModels/ModelMacroDefinition.swift +++ b/Sources/ManagedModels/ModelMacroDefinition.swift @@ -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/*, names: named(init)*/) public macro _PersistedProperty() = #externalMacro(module: "ManagedModelMacros", type: "PersistedPropertyMacro") From 7034247e0b0668ef3f29adc233cbbbef659458a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Kope=C4=87?= Date: Tue, 30 Jan 2024 17:12:55 +0100 Subject: [PATCH 5/6] Changed Xcode version to 15.2 in GitHub Actions This changes the `xcode-version` parameter of the workflow to use Xcode 15.2 in order to check for proper compilation on the latest release --- .github/workflows/swift.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 18a5d8c..927c848 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -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 From 4162d588aff8d94c9a8215cde3e8f76be9c131d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helge=20He=C3=9F?= Date: Tue, 30 Jan 2024 18:01:15 +0100 Subject: [PATCH 6/6] Completely remove init name for _PersistentProperty Not needed. --- Sources/ManagedModels/ModelMacroDefinition.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/ManagedModels/ModelMacroDefinition.swift b/Sources/ManagedModels/ModelMacroDefinition.swift index 77324b5..2b87768 100644 --- a/Sources/ManagedModels/ModelMacroDefinition.swift +++ b/Sources/ManagedModels/ModelMacroDefinition.swift @@ -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")