SwiftUI Previews process isolation default changes in Xcode 16 affect memory attribution
0 reputation · 03 Mar 2023, 16:03 UTC
SwiftUI Previews execution moved out of the Xcode process with process isolation introduced in Xcode 15 and continued in Xcode 16. The default now runs the preview agent in a separate, restartable process for Swift packages and app targets, which changes where preview memory is attributed.
The configuration transition is documented via the PREVIEW_DISABLE_PROCESS_ISOLATION build setting and Preview Canvas options in scheme settings. This creates a compatibility boundary between projects created before the default change and projects created after it, with version and host differences possible.
With the agent lifecycle managed automatically, the documented behavior for teardown timing remains unclear. There is no documented developer control for explicit release of preview agent memory.
What is the documented teardown timing for the preview agent when the canvas is closed or Xcode is idle? Is there a supported way to force explicit teardown of the preview agent process? How does memory accounting differ between the Xcode 15 isolation introduction and the Xcode 16 default for Swift packages?