After upgrading to MacOS Sequoia and Xcode 16 my app was behaving oddly. While running the application from Xcode, the app appears to save data, but running the app again from Xcode, the data is not there. If I open the app on the iPhone, run it and create data, the data persists even after I kill the app from the app switcher.
I went many rounds through my code and found nothing that helped. I finally ran the sample app that appears when you begin a new project and that is behaving the same way. There are errors thrown.
error: the replacement path doesn't exist: "/var/folders/qv/m7sk8kcd3713j3l4bg8wt1lw0000gn/T/swift-generated-sources/@_swiftmacro_13SwiftDataTest11ContentViewV5items33_BCE1062261466603F5F86A688789BF68LL5QueryfMa.swift" error: the replacement path doesn't exist: "/var/folders/qv/m7sk8kcd3713j3l4bg8wt1lw0000gn/T/swift-generated-sources/@_swiftmacro_13SwiftDataTest11ContentViewV5items33_BCE1062261466603F5F86A688789BF68LL5QueryfMa.swift" error: the replacement path doesn't exist: "/var/folders/qv/m7sk8kcd3713j3l4bg8wt1lw0000gn/T/swift-generated-sources/@_swiftmacro_13SwiftDataTest11ContentViewV5items33_BCE1062261466603F5F86A688789BF68LL5QueryfMa.swift"
"I stop the app with the stop button in Xcode. I launch the app from Xcode again. The data is gone."
OK, I tried the sample again on my iOS 18 simulator (22A3351) and did see the issue: If I stop running the app immediately after adding a trip, the trip is not persisted.
I believe this is related to the timing of autosave
– If I save the context explicitly after adding the trip, as shown below, the issue will go away:
private func addTrip() {
withAnimation {
let newTrip = Trip(name: name, destination: destination, startDate: startDate, endDate: endDate)
modelContext.insert(newTrip)
do {
try modelContext.save()
} catch {
print("Failed to save model context: \(error)")
}
}
}
@cmartinpilot and @purelyapps: Would you mind to double check if you see the same thing on your side?
If that is the case, you can fix the issue by saving the context after making a change. Meanwhile, I’d suggest that you file a feedback report to see if the SwiftData folks would see that a bug – If you do so, please share your report ID here.
Regarding the other error messages:
"error: the replacement path doesn't exist: ..."
This is a known bug that folks reported months ago, as discussed in the error: the replacement path doesn't exist: post. You can verify if it is still there with the latest iOS 18.1 beta.
"<0x134159cc0> Gesture: System gesture gate timed out. ... -[RTIInputSystemClient remoteTextInputSessionWithID:performInputOperation:] perform ..."
These messages are log noice. You can safely ignore them, as described in On Log Noise.
Best,
——
Ziqiao Chen
Worldwide Developer Relations.