This can be easily reproduced in a vanilla Xcode 16 beta 3 project.
Steps
- Create a new project.
- By default, previews work fine because default SWIFT_COMPILATION_MODE is Incremental. (aka Batch Mode)
- Now, change it to WMO, and notice the previews crash with the enclosed crash report.
Feedback filed with reproducer + diagnostics + crash report: https://feedbackassistant.apple.com/feedback/14268698
We have observed that enabling Whole Module Optimization (WMO) improves build times in our project. Therefore, if Previews can be compatible with WMO, it would be highly beneficial. Otherwise, it would be helpful to provide a warning or feedback to developers, as many projects are likely utilizing WMO, and identifying issues solely from crash reports can be challenging.
Note: This works all fine with the Legacy Previews Engine in Xcode 15/16.