All Questions
14
questions
0
votes
1
answer
162
views
How to decouple Swift Data from a SwiftUI view in order to make the view available as a Swift Package?
I am working with Swift Data (iOS 17 or higher only) and SwiftUI on iOS.
This question is probably only worth reading (or deciding whether to vote to close!!!) if you are highly active with this ...
1
vote
1
answer
81
views
Registering a ValueTransformer for use in SwiftUI Previews
I'm experimenting with using ValueTransformers in a SwiftUI/SwiftData app to handle models that contain Measurement types.
Although the app works as expected when it's run in the simulator, Xcode ...
1
vote
0
answers
112
views
SwiftData specialized Schema.Relationship.init (name:valueType:keypath:metadata:)
Users on TestFlight have started seeing this crash. Any suggestions?
No changes were made to the swift data schema between builds and the install works on my device.
UPDATE:
New device install error
&...
1
vote
0
answers
293
views
SwiftUI - Share SwiftData View with Widget
I have a SwiftData model called Diem. I want my App and my WidgetExtension to share DiemSharedView (already having both App and Widget as targets). However, DiemSharedView just doesn't show up on my ...
1
vote
1
answer
577
views
SwiftUI - NavigationLink(value: ) and navigationDestination not working
I have a SwiftData model called Diem with variables id, name, and date. I want to navigate from HomeView to DiemDetail, but the NavigationLink does not work. Xcode shows no errors.
struct HomeView: ...
0
votes
3
answers
282
views
"Cannot Synthesize" -- Why is this class not ready to be declared "@Model" for use with SwiftData?
I am trying to convert the Landmarks app to SwiftData... why isn't this class conforming to codable/decodable? It won't compile but the messages are non-specific:
"Type 'Landmark' does not ...
0
votes
1
answer
508
views
Can't Convert SwiftData Model Data to expected argument type NSManagedObject
I have been in the process recently converting my app CoreData code to SwiftData. I have the read and write operations working but ran into a problem with onDelete. I'm guessing that onDelete doesn't ...
4
votes
2
answers
2k
views
SwiftData struggles. Cannot insert 'MyClass' in this managed object context because it is not found in the associated managed object model
My App is crashing trying to insert into a ModelContext. Anything obvious that sticks out as to why?
@Model
class MyDataClass {
var number : String
var pageNumberInDocument : Int
...
3
votes
1
answer
256
views
SwiftData app crashes only when deployed via TestFlight
This SwiftData issue has me stumped. My app, when uploaded via cable works fine but when it is deployed via TestFlight it crashes immediately on startup while trying to do the first fetch for data.
...
4
votes
1
answer
679
views
Xcode 15, iOS 17 - Archive Failed - File name too long
Working on Xcode 15 GA. I'd like to archive my new iOS 17 project, which works properly on iOS and macOS (includes SwiftData library, new WidgetKit extension and StoreKit). However, when I'm trying to ...
5
votes
0
answers
753
views
SwiftData sort or filter enum property
Now that SwiftData can correctly store enums in our models, I am now having difficulties trying to filter or sort on that property.
For example
status is an enum
enum Status: String, Codable, ...
2
votes
1
answer
2k
views
How to access same SwiftData Model Container inside Observable Store
I am trying to access same model container inside Observable class which i have provided to Scene
var body: some Scene {
WindowGroup {
ContentView()
}.modelContainer(for: [Product.self]...
2
votes
1
answer
572
views
SwiftData error NSInvalidArgumentException when assigning relationship
I have the following code:
import SwiftUI
import SwiftData
struct ContentView: View {
@Environment(\.modelContext) private var modelContext
var body: some View {
VStack {
...
16
votes
8
answers
8k
views
How to resolve SwiftData error "Type '*' does not conform to protocol 'PersistentModel'"
Working through the betas of SwiftData and trying to stand up a PersistentContainer. I set up a modelContainer View modifier on my ContentView and conformed my class to @Model as described in various ...