I'm still seeing the issue on Xcode 16.1 and iOS 18.1.
Post
Replies
Boosts
Views
Activity
I received the following message from Apple Feedback Assistant.
Thank you for filing the feedback report. We have deployed the fix. Please verify this issue with iOS 18.1 Beta 6 and update your bug report with your results by logging into https://feedbackassistant.apple.com/ or by using the Feedback Assistant app.
iOS 18.1 Beta 6 (Build: 22B5069a)
https://developer.apple.com/download/
Posted Date: October 7, 2024
I don't have iOS 18.1 Beta 6 on any of my devices. Is there anyone who does and can confirm the fix?
I've updated my feedback to say that the problem exists when using Xcode 16 RC.
A code snippet might help.
I'm easter egging here. Could it be something like the objective c array is a reference type and the [String] is a value type?
I've submitted feedback FB14898357 on this.
Problem solved by insuring that the task is on the main actor. I've removed the feedback.
@FPST I had to write a method that returned the models from a sorted fetch and then get their PersistentIdentifiers.
public func fetchSort<T: PersistentModel>(_ descriptor: FetchDescriptor<T>) throws -> [PersistentIdentifier] {
var result = [PersistentIdentifier]()
var models = [T]()
models = try self.modelContext.fetch(descriptor)
for model in models {
let pID = model.persistentModelID
result.append(pID)
}
return result
}
let fetchDescriptor = FetchDescriptor() works fine, but
let fetchDescriptor = FetchDescriptor<MyModel>(sortBy: [SortDescriptor( \.title)])
fails with
The operation couldn’t be completed. (SwiftData.SwiftDataError error 1.)
I see where you define container1. You have a private var context which you never initialize like
context = ModelContext(container1).
I filed a feedback on the crash. It's FB14766558.
I have two screenshots of the threads, one under Swift 5 and one under Swift 6. I set a breakpoint in the updateView method. The Swift 5 run gets to the breakpoint. The Swift 6 run does not and crashes.
Swift 5
Swift 6
Any help would be most appreciated. Or maybe this is ripe for a bug report?
I've discovered where the crash is occurring. I have an @objc function called updateView() that is fired when the view controller detects NSPersistenStoreRemoteChange. As soon as I save an object in another view, the update fires and the app crashes.
NotificationCenter.default.addObserver(self, selector: #selector(updateView(_ :)), name: .NSPersistentStoreRemoteChange, object: nil)
The crash does not occur using Swift 5.
I now understand the the warnings go away under Swift 6 as 'InferSendableFromCaptures' has been enabled. I still have the crash. Guess I better dig in.
I don't see where you used the @Model macro to change your classes into SwiftData. Did I miss something?