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.

Still having this issue. Have tried the recommended. The main issue that I think this causes is that it does not save SwiftData when the simulator is closed. The data is only saved if you wait a while after making the change or specifically save the context after every right, or close the app in the simulator. But not if I just rebuild or stop the simulator.

I'm having the same issue here. Followed the suggestions here and no luck. Haven't tried the beta update but sounds like its still there. Is this an actual error since it's colored green on the console?

Also getting the same logs in Xcode:

error: the replacement path doesn't exist:

I'm not sure if this is debug log noise or something that needs to be fixed.

I also had this issue when refactoring code to use SwiftData. I had marked several properties with the attribute Transient that I did not want to store. When I realized that Views no longer detected changes to these Transient properties, I converted some of these properties from Transient to the Attribute ephemeral. This solved my View update problem. The App worked fine on first launch and pre-populated the data store with default values and allowed me to update and save data. But I would get the error on subsequent launches and the App would crash when fetching the data from the Model that had a mix of Transient and ephemeral. Other Models that had only Transient macro marked properties were fine. Removing the ephemeral attribute and keeping only the Transient macro in my Model eliminated this problem for me.

error: the replacement path doesn't exist:
 
 
Q