gpt4 book ai didi

ios - SwiftUI 预览版因 stackoverflow 崩溃

转载 作者:行者123 更新时间:2023-11-29 05:40:02 25 4
gpt4 key购买 nike

在现有的应用程序中,我想尝试使用 SwiftUI 来处理一些小 View 。我在 macOS Catalina 和 Xcode 11 中打开了我的项目,并添加了一个 SwiftUI 类。

令我惊讶的是,我收到以下错误:

Cannot preview in this file -- YourApp.app may have crashed

位于预览窗口顶部。

当我查看崩溃日志时,我发现这是由于 stackoverflow 错误造成的:

崩溃线程:0 调度队列:com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00007ffee98cfff8
Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [37403]

External Modification Warnings:
Thread creation by external task.

VM Regions Near 0x7ffee98cfff8:
MALLOC_SMALL 00007fa424000000-00007fa424800000 [ 8192K] rw-/rwx SM=PRV
--> STACK GUARD 00007ffee60d0000-00007ffee98d0000 [ 56.0M] ---/rwx SM=NUL stack guard for thread 0
Stack 00007ffee98d0000-00007ffeea0d0000 [ 8192K] rw-/rwx SM=ALI thread 0

Application Specific Information:
CoreSimulator 643.8.4 - Device: iPhone Xʀ (1C2CE9A2-334D-4A62-8AE9-C6CCC6D346E6) - Runtime: iOS 13.0 (17A5492t) - DeviceType: iPhone Xʀ

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 MessageView.2.preview-thunk.dylib 0x000000012f726918 -[UIViewController(PageViewLogging) ms_viewWillAppear:] + 34
1 MessageView.2.preview-thunk.dylib 0x000000012f72691b -[UIViewController(PageViewLogging) ms_viewWillAppear:] + 37
2 MessageView.2.preview-thunk.dylib 0x000000012f72691b -[UIViewController(PageViewLogging) ms_viewWillAppear:] + 37
3 MessageView.2.preview-thunk.dylib 0x000000012f72691b -[UIViewController(PageViewLogging) ms_viewWillAppear:] + 37
...
508 MessageView.2.preview-thunk.dylib 0x000000012f72691b -[UIViewController(PageViewLogging) ms_viewWillAppear:] + 37
509 MessageView.2.preview-thunk.dylib 0x000000012f72691b -[UIViewController(PageViewLogging) ms_viewWillAppear:] + 37
510 MessageView.2.preview-thunk.dylib 0x000000012f72691b -[UIViewController(PageViewLogging) ms_viewWillAppear:] + 37
511 MessageView.2.preview-thunk.dylib 0x000000012f72691b -[UIViewController(PageViewLogging) ms_viewWillAppear:] + 37

最佳答案

这是因为您在 AppDelegatedidFinishLaunchingWithOptions 中使用了外部框架。当您处理 SwiftUI 代码时清除该方法,它将按预期工作。

不完全确定这是为什么,但这可能是因为 SwiftUI 运行应用程序的实例来渲染它,并使用 AppDelegate 来执行此操作。

关于ios - SwiftUI 预览版因 stackoverflow 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56647978/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com