error: the replacement path doesn't exist:

I'm using SwiftData with an @Model and am also using an @ModelActor. I've fixed all concurrency issues and have migrated to Swift 6. I am getting a console error that I do not understand how to clear. I get this error in Swift 6 and Swift 5. I do not experience any issue with the app. It seems to be working well. But I want to try to get all issues taken care of. I am using the latest Xcode beta.

error: the replacement path doesn't exist: "/var/folders/1q/6jw9d6mn0gx1znh1n19z2v9r0000gp/T/swift-generated-sources/@_swiftmacro_17MyAppName14MyModelC4type18_PersistedPr> opertyfMa.swift"

I do not have 18.1 Beta 6.

I started seeing the same issue after restructuring / refactoring some of my Swift projects - all of them relying on newly introduced @Macro syntax elements.

Good news: the error is unrelated to SwiftData and the crashes described further down in this thread are also unrelated to it (neither of my projects uses SwiftData so QED). I believe people are just seeing it more frequent on Xcode 16 + SwiftData because of the heavy use of Macros it introduced.

Using "Product" > "Clean Build Folder.." didn't solve the issue, however what did was the following:

  • "Product" > "Show Build Folder in Finder"
  • navigate up until you're in XCode's "DerivedData" folder
  • find and delete all folders starting with your Projects Name + some random identifier
  • restart Xcode
  • rebuild

So for example my project was called "GPS.io" and the folder was named something like "GPS.io-gsytifiksezewoesjjyadyzossvf" located in "/Users/USERNAME/Library/Developer/Xcode/DerivedData"

[EDIT] I'm on XCode 16.0 (16A242d) and testing against iOS 18.0

Fixed by cleaning XCode's "DerivedData" folder. from the terminal just run this command

rm -rf ~/Library/Developer/Xcode/DerivedData

I'm still seeing the issue on Xcode 16.1 and iOS 18.1.

i have same problem when i get more than one instance of @ModelActor , if i generate single instance and share between tasks, problem solved. Bu this method not best practice!

Someone know solution ?

I have also hit this issue (and continue to do so despite trying all the suggestions made so far). I have clicked on the feedback link, but then just get a feedback not found screen. Has the link changed. Please can you advise?

error: the replacement path doesn't exist:
 
 
Q