Skip to content

Commit 13f62cc

Browse files
committed
Merge branch 'develop'
2 parents 064d17c + 2d813ec commit 13f62cc

File tree

3 files changed

+39
-31
lines changed

3 files changed

+39
-31
lines changed

README.md

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h2>ManagedModels for CoreData
2-
<img src="https://zeezide.com/img/lighter/Lighter256.png"
2+
<img src="https://zeezide.com/img/managedmodels/ManagedModels128.png"
33
align="right" width="64" height="64" />
44
</h2>
55

@@ -82,8 +82,8 @@ struct ContentView: View {
8282
}
8383

8484
#Preview {
85-
ContentView2()
86-
.modelContainer(for: ContentView2.Item.self, inMemory: true)
85+
ContentView()
86+
.modelContainer(for: Item.self, inMemory: true)
8787
}
8888
```
8989

@@ -103,6 +103,13 @@ The macro implementation requires Xcode 15/Swift 5.9 for compilation.
103103
The generated code itself though should backport way back to
104104
iOS 10 / macOS 10.12 though (when `NSPersistentContainer` was introduced).
105105

106+
Package URL:
107+
```
108+
https://github.com/Data-swift/ManagedModels.git
109+
```
110+
111+
ManagedModels has no other dependencies.
112+
106113

107114
#### Differences to SwiftData
108115

@@ -126,25 +133,25 @@ iOS 10 / macOS 10.12 though (when `NSPersistentContainer` was introduced).
126133

127134
#### TODO
128135

129-
- [ ] Archiving/Unarchiving, required for migration.
130-
- [ ] Figure out whether we can do ordered attributes.
131-
- [ ] Figure out whether we can add support for array toMany properties.
132-
- [ ] Support for "autosave".
133-
- [ ] Support transformable types, not sure they work right yet.
134-
- [ ] Generate property initializers if the user didn't specify any inits?
135-
- [ ] Generate `fetchRequest()` class function.
136-
- [ ] Support SchemaMigrationPlan/MigrationStage.
136+
- [x] Archiving/Unarchiving, required for migration.
137+
- [ ] Figure out whether we can do ordered attributes: [Issue #1](https://github.com/Data-swift/ManagedModels/issues/1).
138+
- [ ] Figure out whether we can add support for array toMany properties: [Issue #2](https://github.com/Data-swift/ManagedModels/issues/2)
139+
- [ ] Support for "autosave": [Issue #3](https://github.com/Data-swift/ManagedModels/issues/3)
140+
- [ ] Support transformable types, not sure they work right yet: [Issue #4](https://github.com/Data-swift/ManagedModels/issues/4)
141+
- [ ] Generate property initializers if the user didn't specify any inits: [Issue #5](https://github.com/Data-swift/ManagedModels/issues/5)
142+
- [x] Generate `fetchRequest()` class function.
143+
- [ ] Support SchemaMigrationPlan/MigrationStage: [Issue #6](https://github.com/Data-swift/ManagedModels/issues/6)
137144
- [ ] Write more tests.
138-
- [ ] Write DocC docs.
139-
- [ ] Support for entity inheritance.
140-
- [ ] Add support for originalName/versionHash in `@Model`.
141-
- [ ] Generate "To Many" accessor function prototypes (`addItemToGroup` etc).
142-
- [ ] Foundation Predicate support (would require iOS 17+)
143-
- [ ] SwiftUI `@Query` property wrapper/macro?
145+
- [ ] Write DocC docs: [Issue #7](https://github.com/Data-swift/ManagedModels/issues/7), [Issue #8](https://github.com/Data-swift/ManagedModels/issues/8)
146+
- [ ] Support for entity inheritance: [Issue #9](https://github.com/Data-swift/ManagedModels/issues/9)
147+
- [ ] Add support for originalName/versionHash in `@Model`: [Issue 10](https://github.com/Data-swift/ManagedModels/issues/10)
148+
- [ ] Generate "To Many" accessor function prototypes (`addItemToGroup` etc): [Issue 11](https://github.com/Data-swift/ManagedModels/issues/11)
149+
- [x] Foundation Predicate support (would require iOS 17+) - this seems actually supported by CoreData!
150+
- [ ] SwiftUI `@Query` property wrapper/macro?: [Issue 12](https://github.com/Data-swift/ManagedModels/issues/12)
144151
- [ ] Figure out all the cloud sync options SwiftData has and whether CoreData
145-
can do them.
152+
can do them: [Issue 13](https://github.com/Data-swift/ManagedModels/issues/13)
146153
- [ ] Figure out whether we can allow initialized properties
147-
(`var title = "No Title"`).
154+
(`var title = "No Title"`): [Issue 14](https://github.com/Data-swift/ManagedModels/issues/14)
148155

149156
Pull requests are very welcome!
150157
Even just DocC documentation or more tests would be welcome contributions.
@@ -155,8 +162,16 @@ Even just DocC documentation or more tests would be welcome contributions.
155162
- Apple:
156163
- [CoreData](https://developer.apple.com/documentation/coredata)
157164
- [SwiftData](https://developer.apple.com/documentation/swiftdata)
165+
- [Meet SwiftData](https://developer.apple.com/videos/play/wwdc2023/10187)
166+
- [Build an App with SwiftData](https://developer.apple.com/videos/play/wwdc2023/10154)
167+
- [Model your Schema with SwiftData](https://developer.apple.com/videos/play/wwdc2023/10195)
168+
- [Enterprise Objects Framework](https://en.wikipedia.org/wiki/Enterprise_Objects_Framework) / aka EOF
169+
- [Developer Guide](https://developer.apple.com/library/archive/documentation/LegacyTechnologies/WebObjects/WebObjects_4.5/System/Documentation/Developer/EnterpriseObjects/DevGuide/EOFDevGuide.pdf)
158170
- [Lighter.swift](https://github.com/Lighter-swift), typesafe and superfast
159171
[SQLite](https://www.sqlite.org) Swift tooling.
172+
- [ZeeQL](http://zeeql.io), prototype of an [EOF](https://en.wikipedia.org/wiki/Enterprise_Objects_Framework) for Swift,
173+
with many database backends.
174+
160175

161176

162177
#### Disclaimer

Sources/ManagedModels/SchemaCompatibility/NSAttributeDescription+Data.swift

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ extension CoreData.NSAttributeDescription: SchemaProperty {
7373
self.attributeValueClassName = "NSNumber"
7474
}
7575
else if newValue == String.self {
76-
self.attributeType = .integer64AttributeType
76+
self.attributeType = .stringAttributeType
7777
self.isOptional = false
7878
self.attributeValueClassName = "NSString"
7979
}
8080
else if newValue == String?.self {
81-
self.attributeType = .integer64AttributeType
81+
self.attributeType = .stringAttributeType
8282
self.isOptional = true
8383
self.attributeValueClassName = "NSString"
8484
}
@@ -182,16 +182,6 @@ extension CoreData.NSAttributeDescription: SchemaProperty {
182182
self.isOptional = true
183183
self.attributeValueClassName = "NSNumber"
184184
}
185-
else if newValue == Int32.self {
186-
self.attributeType = .integer32AttributeType
187-
self.isOptional = false
188-
self.attributeValueClassName = "NSNumber"
189-
}
190-
else if newValue == Int32?.self {
191-
self.attributeType = .integer32AttributeType
192-
self.isOptional = true
193-
self.attributeValueClassName = "NSNumber"
194-
}
195185
else {
196186
// TBD:
197187
// undefinedAttributeType = 0

Tests/ManagedModelTests/SchemaGenerationTests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ final class SchemaGenerationTests: XCTestCase {
2828
XCTAssertTrue (toAddresses.isRelationship)
2929
XCTAssertFalse(toAddresses.isToOneRelationship)
3030

31+
XCTAssertEqual(firstname.attributeType, .stringAttributeType)
32+
XCTAssertTrue(firstname.valueType == String.self)
33+
3134
// Those can't be setup yet.
3235
XCTAssertTrue(toAddresses.destination.isEmpty)
3336
XCTAssertNil(toAddresses.inverseName)

0 commit comments

Comments
 (0)