Failed to create temporary staging dir

When running unit tests for a second+ time, we often run into:


"Failed to create temporary staging dir in <PATH_TO_SIMULATOR>/data/Library/Caches/com.apple.mobile.installd.staging"


If we delete derived data, it always works the first run, but then fails on subsequent runs.


Something in Xcode is deleting the directory it needs. Has anyone else seen this and found a solution?

Did you find a solution to this problem? I am still experiencing it with XCode 11.2


Similar bug report: https://github.com/fastlane/fastlane/issues/13618


I have this issue happening with multiple projects. Happens when trying to simply install my app to a simulator in XCode and happens when trying to run tests via CLI.

This happened to me when I deleted files in /Library/Developer/CoreSimulator to save space. Make sure to Erase All Content and Settings for the Simulator you're trying to use--this worked for me. My guess is that it's looking for that same Simulator device ID to stage these files, but it's been deleted.
Failed to create temporary staging dir
 
 
Q