应用程序崩溃,出现UIApplicationEndBackgroundTaskError

Geo*_*e_E 8 ios appdelegate sprite-kit swift swiftui

上下文:我的应用是使用SwiftUI制作的,SwiftUI是使用SpriteKit的游戏。

在设备上按下主屏幕按钮时,我的应用遇到了名为“ UIApplicationEndBackgroundTaskError” 的错误。日志如下所示:

Can't end BackgroundTask: no background task exists with identifier 1 (0x1), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.

我已经尝试过创建断点,但是它并没有提供我所了解的任何有用信息。没有日志,仅显示“调试导航器”。

调试导航器

我试图调查问题的出处。我只是添加了一些简单的打印语句。Update在断点暂停应用程序之前,打印会快速重复几次:

struct SceneView: UIViewRepresentable {

    let bounds: CGRect


    // Conformance to UIViewRepresentable
    func makeUIView(context: Context) -> SKView {
        SKView(frame: bounds)
    }
    func updateUIView(_ uiView: SKView, context: Context) {
        print("Update")

        let scene = Scene(size: bounds.size)
        uiView.ignoresSiblingOrder = true
        uiView.showsFPS = true
        uiView.showsDrawCount = true
        uiView.showsNodeCount = true
        uiView.presentScene(scene)
    }
}
Run Code Online (Sandbox Code Playgroud)
  • 是什么原因引起的,如何解决这个问题?
  • 这可能是由于SwiftUI还是我的Xcode Beta和iPhone Beta不匹配?

JER*_*ERC 2

它已在 iOS 13.2 beta 3 上修复,你可以在那里测试它,它应该已修复。

  • 你能分享源码吗? (4认同)