I'm also having problem with "Replace Container" on real device.
Even when I tried to create new iOS application to test it, when I replace the container, the application crashes.
Easy way to replicate problem:
Step 1:
In Xcode, using project template, create new iOS application with CoreData support.
Step 2:
Build application and run it on real device with iOS 17.
Step 3:
Download Container for this application using Xcode. {menu - Window - Devices and Simulator).
Step 4:
Replace Container (the same container previously downloaded) using Xcode {menu - Window - Devices and Simulator).
Step 5:
Run application again on real device = crash/error.
Errors:
error: Failed to create directory: NSCocoaErrorDomain (513)
CoreData: Unhandled exception finding default Directory URL '+[NSPersistentContainer defaultDirectoryURL] Could not conjure up a useful location for writing persistent stores.'
My system configuration for development:
Xcode 15.0.1 (also tested with Xcode 15.1 beta 3 with same error)
iOS 17.1.2, iPadOS 17.1.2 (real devices iPhone, iPad)