Xcode 11: SwiftUI preview not working

I created a simple test project in Xcode 11 (on Catalina) and was able to see the previews for the SwiftUI views and their settings etc.


I then opened an small established project I have and did all the updates that Xcode 11 suggested to bring it up to spec. Then I added a SwiftUI view using the SwiftUI template. Everything compiles fine, but when I attempt to see the preview of the SwiftUI view I get this error:


messageRepliedWithError("Connecting to launched interactive agent 1590", 
Optional(Error Domain=com.apple.dt.ultraviolet.service Code=17 
"connectToPreviewHost: Failed to connect to 1590: Error Domain=com.apple.dt.ProcessAttachUtilities Code=3 
"Target process 1590 exited prematurely, likely crashed" 
UserInfo={NSLocalizedDescription=Target process 1590 exited prematurely, likely crashed}" 
UserInfo={NSLocalizedDescription=connectToPreviewHost: Failed to connect to 1590: 
Error Domain=com.apple.dt.ProcessAttachUtilities Code=3 "Target process 1590 exited prematurely, likely crashed" 
UserInfo={NSLocalizedDescription=Target process 1590 exited prematurely, likely crashed}}))


I've tried all sorts of things and looked for settings I might have missed but so far I've not been able to figure this out (also rebooted the machine).


Anyone happen to come across this and figure it out?

Answered by drekka in 365863022

Digging around in the crash logs I found references to the Thread Sanitizer. So I turned it off and now I have this error:


Points Master.app: Error Domain=com.apple.dt.UITestingAgent Code=-1 
"Preview provider "13Points_Master17MainView_PreviewsV" does not exist" 
UserInfo={NSLocalizedDescription=Preview provider "13Points_Master17MainView_PreviewsV" does not exist}


So I was thinking one step a head then I figured out my project didn't have the 'DEBUG' active compilation condition so the SwiftUI preview functions where not visible to Xcode.


It's all now working.

Accepted Answer

Digging around in the crash logs I found references to the Thread Sanitizer. So I turned it off and now I have this error:


Points Master.app: Error Domain=com.apple.dt.UITestingAgent Code=-1 
"Preview provider "13Points_Master17MainView_PreviewsV" does not exist" 
UserInfo={NSLocalizedDescription=Preview provider "13Points_Master17MainView_PreviewsV" does not exist}


So I was thinking one step a head then I figured out my project didn't have the 'DEBUG' active compilation condition so the SwiftUI preview functions where not visible to Xcode.


It's all now working.

Xcode 11: SwiftUI preview not working
 
 
Q