简体   繁体   English

SwiftUI 预览错误:连接到启动的交互式代理

[英]SwiftUI previews error: Connecting to launched interactive agent

I received the above error when using the SwiftUI previews feature and can't figure out why this happens.我在使用 SwiftUI 预览功能时收到上述错误,但无法弄清楚为什么会发生这种情况。 The error always looks something like this:错误总是如下所示:

GenericHumanReadableError: unexpected error occurred

messageRepliedWithError("Connecting to launched interactive agent 1894", Optional(Error Domain=com.apple.dt.xcodepreviews.service Code=17 "connectToPreviewHost: Failed to connect to 1894: (null)" UserInfo={NSLocalizedDescription=connectToPreviewHost: Failed to connect to 1894: (null)}))

I managed to figure out a good way to debug this, please see below我设法找到了调试它的好方法,请参见下文

If you head into /Users/USERNAME/Library/Logs/DiagnosticReports you will see the latest crash reports.如果您进入/Users/USERNAME/Library/Logs/DiagnosticReports ,您将看到最新的崩溃报告。 Open the most recent one (should start with your app name), and it should tell you the reason the app crashed.打开最近的一个(应该以您的应用程序名称开头),它应该会告诉您应用程序崩溃的原因。 It'll look something like this:它看起来像这样:

Application Specific Information:
Fatal error: This request requires an authenticated account: file /Users/USERNAME/Work/AppName/Models/CloudKitAlbumManager.swift, line 101

In my case, it was a fatalError i threw in development for debugging.就我而言,这是我在开发中为调试而投入的致命错误。 The previews loads your app and thus call your whole stack and will crash if you like me throws fatalErrors for debugging.预览会加载您的应用程序并因此调用您的整个堆栈,如果您喜欢我抛出 fatalErrors 进行调试,它将崩溃。

I hope this helps我希望这有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM