Beta 2 is out and seems to have added support for SwiftData. 🤷♂️ at least it works fine for me.
Post
Replies
Boosts
Views
Activity
I also tried
let servers = Query(FetchDescriptor<MY_DATA_CLASS>()).wrappedValue
but get the error
Set a .modelContext in view's environment to use Query
I have this in the top of the class, but I assume it hasnt been initialized yet?
@Environment(\.modelContext) private var modelContext
after more debugging, calling the code inside onappear instead of init seems to have solved the issue
Same issue here. Assuming it will be fixed once the new xcode beta comes out.
Did you ever find a solution? im having the same issue, where after the app is restarted, all the data is lost, but only once I start accessing the swift data from the background context.
For anyone else seeing this, from the related Github thread, it seems to be due to the custom init defined.
Temporarily making the init only accessible via a static method seems to be a temporary bypass to avoid the build error
https://github.com/apple/swift/issues/67823#issuecomment-1673842437
add this inside your swift model, and only instantiate the model via a static method when calling from the parent package.
public static func create(value: String) -> Note {
Note(value)
}
hopefully this is fixed in the next release.
Hi Ed ( @DTS Engineer) thanks for this super helpful info.
Just wanted to ask a follow-up question on the optimal way apple recommends handling AppIntentsExtension?
I currently have an AppIntentsExtension which contains my AppShortcutsProvider and AppIntent, and those are not compiled into my main app.
Currently, this works fine, but my main issue is I am not able to call updateAppShortcutParameters from my main app to tell iOS to requery my parameters for my sirishortcuts.
What is the recommended way for me to solve this, should I create a framework with those app intents and shortcut provider, and link the framework in both the AppIntentsExtension and main app?
or should I try just have the file in one of them, and adding those files as targets to both the AppIntentsExtension and main app?
Any help is greatly appreciated!
Im having the same issue and confusion. Tried many combinations of sizes, but can't get anything to be consistent. Did you find a solution?
This was answered here, the answer Is you need to add the main app as a target in your shortcut provider
https://forums.developer.apple.com/forums/thread/759160?answerId=806728022#806728022
@Minegishi did you ever find a solution? I'm running into the same problem https://forums.developer.apple.com/forums/thread/766601
@Engineer I've filed a feedback with a simple example project, as well as screen recordings showing the behavior.
Feedback: FB15592256
I also went ahead and duplicated the entire widget, making a second widget with a different "kind" but as can be seen in my screen recording video in the feedback, even the 2 different widgets of different "Kinds" still exhibit this problem and use the old invalid data from the other widget.
I've also uploaded the screen recordings and sample project to my Google Drive if anyone else wants to take a look or reproduce.
https://drive.google.com/drive/folders/1rC413RFtUP5AoBZQy7plaFEABMcKJZvh?usp=sharing
@Engineer any updates? I haven't heard anything back yet from DTS over email or on the Feedback.
Ended up being a totally unrelated problem, the bundle id of the widget accidentally got changed and that caused the migration to fail. Changing the Bundle id back to the original fixed the issue.