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?

When you have this error in the logs, try the following:

  1. Get the derived data folder handy.
  2. Clean and Close Xcode.
  3. Find the following folder:

/var/folders/1q/6jw9d6mn0gx1znh1n19z2v9r0000gp/T/swift-generated-sources

  • The random string could be different for you.

  • Delete the contents of the derived data folder.

  • Delete the contents of the swift-generated-sources.

  • In the var/folder..../T folder, scroll to the tip and also delete any dev related files starting with an _.

Now:

  1. Launch Xcode with your project.
  2. Resolve packages if you have any.
  3. Build and run.
error: the replacement path doesn't exist:
 
 
Q