2021-01-22 Error in SwiftUI Previews part deux

Last edit

Summary: Today Xcode refused to show previews for one view, displaying "Cannot preview this file" on top of the previews canvas. This time it's showing the . . .

Changed:

< - Quit Xcode and simulator
< - Delete the ~/Library/Developer/Xcode/DerivedData folder
< - Start Xcode and simulator
< - Remove all unittests from the project (don't move to trash, simply remove references)
< - Compile the project
< - Add the unittests back to the project

to

> * Quit Xcode and simulator
> * Delete the ~/Library/Developer/Xcode/DerivedData folder
> * Start Xcode and simulator
> * Remove all unittests from the project (don't move to trash, simply remove references)
> * Compile the project
> * Add the unittests back to the project


Today Xcode refused to show previews for one view, displaying "Cannot preview this file" on top of the previews canvas.

This time it's showing the error "SomeUnitTest.swift must belong to at least one target in the current scheme in order to use previews". I have the feeling that this error is incorrect and masks a problem elsewhere, because unittests most certainly should not belong to any other target than the test target.

I have been able to temporarily fix the problem as follows: