我正在将小部件与CoreData和iCloud一起使用。它们共享同一个App Group容器。一切工作正常,但小部件会自发地开始不断重新加载并在设备屏幕和小部件仪表板(您可以在其中搜索和添加任何小部件的地方)中自行阻止。
它发生在iPhone Simulator(我使用iPhone 8)和物理设备上。在设备上,它的运行状况更好,例如,它可以重新加载一段时间,然后停止。
我以为它已连接到NSPersistentContainer
,但不确定。我没有运气尝试过这些:
container.performBackgroundTask()
更快地返回getTimeline(in:completion:)
中的数据。我只测试了1条记录,结果是相同的。在不同的情况下,我会看到以下日志消息:
1) -[EXSwiftUI_Subsystem beginUsing:withBundle:] unexpectedly called multiple times
2) Bogus event received by listener connection
3) [lifecycle] WARNING: Did not receive handshake message from the host after waiting ~2 seconds. THIS MAY BE A SPURIOUS LAUNCH OF THE PLUGIN due to a message to an XPC endpoint other than the main service endpoint, or the CPU is highly contended and this extension or its host is not getting enough CPU time.
有时会崩溃
1) signal SIGTERM
2) [NSConcreteFileHandle fileDescriptor]: unknown error
我不知道为什么会发生。我感到困惑,因为它有时可以工作并显示我的核心数据记录,并正确地重新加载时间线,但有时会发疯。
任何帮助或指导将不胜感激。
Xcode 12.0.1(12A7300)
设备:iPhone Xs,iOS 14.0.1