关于 xcode:使用 Canvas 预览 SwiftUI 视图时出错

Error when using Canvas to preview SwiftUI view

当我尝试在 Xcode 的 Canvas 窗口中预览我的 SwiftUI 视图时,我的项目成功构建,但我在 Canvas 窗口中收到以下错误:

UVIntegration.DTXMessageError.messageRepliedWithError("Connecting to
launched interactive agent 6310", Optional(Error
Domain=com.apple.dt.ultraviolet.service Code=17"connectToPreviewHost:
Failed to connect to 6310: Error Domain=RemoteBundleLoaderError
Code=17"Failed to load library
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks/XCPreviewKit.framework/Versions/Current/XCPreviewKit
due to missing bootstrapping symbols"
UserInfo={NSLocalizedDescription=Failed to load library
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks/XCPreviewKit.framework/Versions/Current/XCPreviewKit
due to missing bootstrapping symbols}"
UserInfo={NSLocalizedDescription=connectToPreviewHost: Failed to
connect to 6310: Error Domain=RemoteBundleLoaderError Code=17"Failed
to load library
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks/XCPreviewKit.framework/Versions/Current/XCPreviewKit
due to missing bootstrapping symbols"
UserInfo={NSLocalizedDescription=Failed to load library
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks/XCPreviewKit.framework/Versions/Current/XCPreviewKit
due to missing bootstrapping symbols}})))

GenericHumanReadableError: unexpected error occurred
messageRepliedWithError("Connecting to launched interactive agent
6310", Optional(Error Domain=com.apple.dt.xcodepreviews.service
Code=17"connectToPreviewHost: Failed to connect to 6310: Error
Domain=RemoteBundleLoaderError Code=17"Failed to load library
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks/XCPreviewKit.framework/Versions/Current/XCPreviewKit
due to missing bootstrapping symbols"
UserInfo={NSLocalizedDescription=Failed to load library
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks/XCPreviewKit.framework/Versions/Current/XCPreviewKit
due to missing bootstrapping symbols}"
UserInfo={NSLocalizedDescription=connectToPreviewHost: Failed to
connect to 6310: Error Domain=RemoteBundleLoaderError Code=17"Failed
to load library
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks/XCPreviewKit.framework/Versions/Current/XCPreviewKit
due to missing bootstrapping symbols"
UserInfo={NSLocalizedDescription=Failed to load library
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks/XCPreviewKit.framework/Versions/Current/XCPreviewKit
due to missing bootstrapping symbols}}))


清理构建文件夹,然后杀死 Xcode,启动 Xcode,进行完整构建可能(有时)会解决问题。然后整个马戏团又开始了。
我认为这对苹果来说有点可惜。最令人沮丧(至少对我而言)是文档几乎不存在。这都是反复试验。主要是错误。


我已经两次遇到这个问题了。我没有一个简单的解决方案,但只有在 macOS Catalina 有可用的软件更新时才会发生。例如,我现在使用的是 10.15.5,但有 10.15.6 的更新,我遇到了这个问题。

希望对您有所帮助,而且错误不只是说"更新您的 macOS"或其他内容,这真的很烦人。