My preview crashed because it could not access my font resources. I am working on a Framework, and it seems that for frameworks, the resources are not copied into the app package of the preview.
Investigation:
I verified this by examining the contents of the preview: /Users/YOUR_NAME/Library/Developer/Xcode/UserData/Previews/Simulator Devices/DEVICE_UUID/data/Containers/Bundle/Application/APPLICATION_UUID/APPLICATION_NAME.app
Make sure to replace "YOUR_NAME," "DEVICE_UUID," "APPLICATION_UUID," and "APPLICATION_NAME" with the actual names or UUIDs relevant to your specific situation.
Now right-click on the app and select Show Package Contents.
For previews that work correctly, the name of the associated app is used, and you will see all the resources in the package.
However, my framework was not using the framework name. Instead, it was named XCPreviewAgent.app and did not contain any resources from my framework.
Fix:
As of November 2024 (Xcode 16.0 and Xcode 16.1), the fix is to use Legacy Preview Execution.
In the menu, select Editor > Canvas > Legacy Preview Execution.
Please leave a comment if this is fixed in a newer Xcode version.