Xcode previews no longer update after changes to files outside of PreviewProvider

Originator:alex
Number:rdar://FB9917445 Date Originated:2/20/22
Status:Open Resolved:
Product:Xcode Product Version:13.2.1
Classification: Reproducible:
 
Please describe the issue:
SwiftUI previews were a godsend, increasing my developer productivity by 1000x with use cases like this:
1) Preview a UIViewController (via UIViewControllerRepresentable)
2) Pin preview
3) Update view controller code and see changes to pinned preview in real time (e.g. saves countless hours configuring composable collection views)
4) Update theme files (colors, styles) and see changes to pinned preview in real time
This all used to work like a charm as long as the updated code was inside functions or computed properties.

But it no longer works:
* Updating any file outside of PreviewProvider struct just reloads the canvas, but does not account for changes in these files (e.g. if I change color in a theme file, the old color will be shown in preview until I build the app again)
* Using "Refresh Canvas" does not solve the issue (it just reloads the canvas with stale data)

Please list the steps you took to reproduce the issue:
1. Open the attached project XcodePreview
2. Open `ContentView.swift`, show and pin preview
3. Open `Theme.swift` and change color

What did you expect to happen?
4. Previews canvas refreshes and color changes immediately

What actually happened?
4. Preview still shows the previous color (given the simplicity of the sample project, it may sometimes change the first time only, but after that will remain the same on all subsequent changes until you rebuild the app; refreshing canvas does not update it)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!