2

I am trying to present a QLPreviewController for a single UIImage. My preview item is as follow:

final class PreviewItem: NSObject, QLPreviewItem {
    let url: URL

    init(url: URL) {
        self.url = url
    }

    var previewItemURL: URL? {
        url
    }
}

And in my view controller I have:

private var previewItems: [QLPreviewItem] = []

func getDocumentsDirectory() -> URL {
    let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
    let documentsDirectory = paths[0]
    return documentsDirectory
}

func saveImage(image: UIImage) -> Bool {
    guard let data = image.jpegData(compressionQuality: 0.8) else { return false }

    let fileName = getDocumentsDirectory().appendingPathComponent("annotate.png")

    guard (try? data.write(to: fileName)) != nil else { return false }

    return true
}

func getPreviewItem() -> PreviewItem? {
    let imageURL = getDocumentsDirectory().appendingPathComponent("annotate.png")
    let imagePath = (getDocumentsDirectory().appendingPathComponent("annotate.png")).path

    guard FileManager.default.fileExists(atPath: imagePath) else { return nil }

    return PreviewItem(url: imageURL)
}

// MARK: - Data Source

func numberOfPreviewItems(in controller: QLPreviewController) -> Int {
    1
}

func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
    previewItems[index]
}

// MARK: - Delegate

func previewController(
    _ controller: QLPreviewController,
    editingModeFor previewItem: QLPreviewItem
) -> QLPreviewItemEditingMode {
    .updateContents
}

When I tap the image the following function is invoked:

private func showEditPhoto(image: UIImage?) {
    guard let image = image, saveImage(image: image), let previewItem = getPreviewItem() else { return }
    previewItems.removeAll()
    previewItems.append(previewItem)

    let vc = QLPreviewController()
    vc.delegate = self
    vc.dataSource = self
    vc.currentPreviewItemIndex = 0
    present(vc, animated: true)
}

However the app is crashing and I am getting the following message:

Thread 1: "*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[2]"

I have debugged the previewItem.previewItemURL?.absoluteString value and get:

file:///Users/kekearif/Library/Developer/CoreSimulator/Devices/D4003825-4548-4DBA-9B34-FCCC4FF5BD17/data/Containers/Data/Application/9FEBD729-30BD-479A-8D0B-60D379CA050F/Documents/annotate.png

So it seems to have found the file correctly. What am I doing wrong here?

EDIT: This seems to only crash in the simulator, crash log:

2022-06-09 17:12:06.357379+0800 Snapask[6552:19316258] [db] _LSSchemaConfigureForStore failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.357504+0800 Snapask[6552:19316258] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.359656+0800 Snapask[6552:19316798] [db] _LSSchemaConfigureForStore failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.359791+0800 Snapask[6552:19316798] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.360137+0800 Snapask[6552:19316569] [db] _LSSchemaConfigureForStore failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.360244+0800 Snapask[6552:19316798] [ls] unable to get LSApplicationExtensionRecord: Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.360339+0800 Snapask[6552:19316569] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.360503+0800 Snapask[6552:19316569] [ls] unable to get LSApplicationExtensionRecord: Error Domain=NSOSStatusErrorDomain Code=-10817 "(2022-06-09 17:12:06.360737+0800 Snapask[6552:19316804] [db] _LSSchemaConfigureForStore failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.369729+0800 Snapask[6552:19316804] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.370013+0800 Snapask[6552:19316258] [db] _LSSchemaConfigureForStore failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.370004+0800 Snapask[6552:19316804] [ls] unable to get LSApplicationExtensionRecord: Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.370108+0800 Snapask[6552:19316258] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.370367+0800 Snapask[6552:19316546] [db] _LSSchemaConfigureForStore failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.370463+0800 Snapask[6552:19316546] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.370592+0800 Snapask[6552:19316546] [ls] unable to get LSApplicationExtensionRecord: Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.370768+0800 Snapask[6552:19316258] [db] _LSSchemaConfigureForStore failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.370862+0800 Snapask[6552:19316258] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.371260+0800 Snapask[6552:19316798] [db] _LSSchemaConfigureForStore failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.371409+0800 Snapask[6552:19316798] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.371522+0800 Snapask[6552:19316798] [ls] unable to get LSApplicationExtensionRecord: Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.371649+0800 Snapask[6552:19316569] [db] _LSSchemaConfigureForStore failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.371767+0800 Snapask[6552:19316569] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.371877+0800 Snapask[6552:19316569] [ls] unable to get LSApplicationExtensionRecord: Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.372620+0800 Snapask[6552:19316546] [db] _LSSchemaConfigureForStore failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.372738+0800 Snapask[6552:19316546] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.372867+0800 Snapask[6552:19316546] [ls] unable to get LSApplicationExtensionRecord: Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.373018+0800 Snapask[6552:19316798] [db] _LSSchemaConfigureForStore failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.373109+0800 Snapask[6552:19316798] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.373226+0800 Snapask[6552:19316798] [ls] unable to get LSApplicationExtensionRecord: Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.374181+0800 Snapask[6552:19316546] [db] _LSSchemaConfigureForStore failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.374268+0800 Snapask[6552:19316546] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.374412+0800 Snapask[6552:19316546] [ls] unable to get LSApplicationExtensionRecord: Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.375259+0800 Snapask[6552:19316546] [db] _LSSchemaConfigureForStore failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.375341+0800 Snapask[6552:19316546] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.375443+0800 Snapask[6552:19316546] [ls] unable to get LSApplicationExtensionRecord: Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.376712+0800 Snapask[6552:19316546] [db] _LSSchemaConfigureForStore failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.376793+0800 Snapask[6552:19316546] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.376904+0800 Snapask[6552:19316546] [ls] unable to get LSApplicationExtensionRecord: Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc07f55ad aa617467 6e0bb79e c1a0d1c3 ... d5844058 fdbbc1ca }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x167f74be 8c26847b be1afbc4 d0f8127e ... 1d550b65 5d17b7d1 }}
2022-06-09 17:12:06.385689+0800 Snapask[6552:19316258] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[2]'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000121c2b604 __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x0000000119a86a45 objc_exception_throw + 48
    2   CoreFoundation                      0x0000000121cacc63 _CFThrowFormattedException + 200
    3   CoreFoundation                      0x0000000121cb7137 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:].cold.5 + 0
    4   CoreFoundation                      0x0000000121c99928 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 243
    5   CoreFoundation                      0x0000000121c2a258 +[NSDictionary dictionaryWithObjects:forKeys:count:] + 49
    6   QuickLook                           0x000000012020b5de __49+[QLItem(PreviewInfo) contentTypesToPreviewTypes]_block_invoke + 484
    7   libdispatch.dylib                   0x00000001218b8a5b _dispatch_client_callout + 8
    8   libdispatch.dylib                   0x00000001218b9f24 _dispatch_once_callout + 66
    9   QuickLook                           0x000000012020b3f8 +[QLItem(PreviewInfo) contentTypesToPreviewTypes] + 46
    10  QuickLook                           0x000000012020bd39 -[QLItem(PreviewInfo) _uncachedPreviewItemTypeForContentType:] + 117
    11  QuickLook                           0x000000012020c2a6 -[QLItem(PreviewInfo) _previewItemTypeForType:] + 150
    12  QuickLook                           0x000000012020c0ac -[QLItem(PreviewInfo) _getPreviewItemType] + 61
    13  QuickLook                           0x00000001202934da -[QLItem previewItemType] + 59
    14  QuickLook                           0x0000000120242d1d +[QLItemFetcherFactory fetcherForPreviewItem:] + 90
    15  QuickLook                           0x0000000120292ba3 -[QLItem fetcher] + 44
    16  QuickLook                           0x00000001201f6828 -[QLPreviewController previewItemAtIndex:withCompletionHandler:] + 153
    17  QuickLook                           0x000000012022c7af __63-[QLPreviewItemStore previewItemAtIndex:withCompletionHandler:]_block_invoke + 262
    18  QuickLook                           0x0000000120260629 QLRunInMainThread + 51
    19  QuickLook                           0x000000012022c67a -[QLPreviewItemStore previewItemAtIndex:withCompletionHandler:] + 181
    20  QuickLook                           0x00000001201f0847 -[QLPreviewController internalCurrentPreviewItem] + 222
    21  QuickLook                           0x0000000120270148 -[QLPreviewController(Overlay) _actionButton] + 344
    22  QuickLook                           0x0000000120270824 -[QLPreviewController(Overlay) _toolBarButtonsWithTraitCollection:] + 1147
    23  QuickLook                           0x000000012026e307 -[QLPreviewController(Overlay) _updateOverlayButtonsIfNeededWithTraitCollection:animated:updatedToolbarButtons:] + 129
    24  QuickLook                           0x000000012026d9aa -[QLPreviewController(Overlay) updateOverlayAnimated:animatedButtons:forceRefresh:withTraitCollection:] + 152
    25  QuickLook                           0x00000001201f06af -[QLPreviewController _setCurrentPreviewItemIndex:updatePreview:animated:] + 230
    26  QuickLook                           0x00000001201f63be -[QLPreviewController reloadData] + 418
    27  QuickLook                           0x0000000120281332 -[QLPreviewController(Transitions) animatorForShowing:previewController:presentingController:] + 86
    28  UIKitCore                           0x000000013a3c04d0 -[UIViewController _customAnimatorForPresentedController:presentingController:sourceController:] + 163
    29  UIKitCore                           0x000000013a3c6533 -[UIViewController _presentViewController:withAnimationController:completion:] + 4826
    30  UIKitCore                           0x000000013a3c737b __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 98
    31  UIKitCore                           0x000000013a3c76b1 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 519
    32  UIKitCore                           0x000000013a3c72d9 -[UIViewController _presentViewController:animated:completion:] + 173
    33  UIKitCore                           0x000000013a3c7767 -[UIViewController presentViewController:animated:completion:] + 155
    34  Snapask                             0x00000001048166b0 $s7Snapask10ChatRoomVCC13showEditPhoto33_246E04EC1A10B7141EA27E662598A727LL5imageySo7UIImageCSg_tF + 688
    35  Snapask                             0x000000010482ac1e $s7Snapask10ChatRoomVCC9tableView_12cellForRowAtSo07UITableF4CellCSo0kF0C_10Foundation9IndexPathVtFyycfU4_ySo13UIAlertActionCcfU_ + 158
    36  Snapask                             0x00000001045e622a $sSo13UIAlertActionCIegg_ABIeyBy_TR + 58
    37  UIKitCore                           0x0000000139f0bf7f -[UIAlertController _invokeHandlersForAction:] + 105
    38  UIKitCore                           0x0000000139f0c868 __103-[UIAlertController _dismissAnimated:triggeringAction:triggeredByPopoverDimmingView:dismissCompletion:]_block_invoke.454 + 16
    39  UIKitCore                           0x000000013a27d21f -[UIPresentationController transitionDidFinish:] + 1269
    40  UIKitCore                           0x000000013a281ee4 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke.437 + 199
    41  UIKitCore                           0x000000013a3de79b -[_UIViewControllerTransitionContext completeTransition:] + 101
    42  UIKitCore                           0x000000013b136944 __UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK__ + 15
    43  UIKitCore                           0x000000013b136c63 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 797
    44  UIKitCore                           0x000000013b106f08 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 190
    45  UIKitCore                           0x000000013b107523 -[UIViewAnimationState animationDidStop:finished:] + 263
    46  UIKitCore                           0x000000013b1076a4 -[UIViewAnimationState animationDidStop:finished:] + 648
    47  QuartzCore                          0x000000011b5a07c6 _ZN2CA5Layer23run_animation_callbacksEPv + 318
    48  libdispatch.dylib                   0x00000001218b8a5b _dispatch_client_callout + 8
    49  libdispatch.dylib                   0x00000001218c7325 _dispatch_main_queue_drain + 1169
    50  libdispatch.dylib                   0x00000001218c6e86 _dispatch_main_queue_callback_4CF + 31
    51  CoreFoundation                      0x0000000121b97ed5 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    52  CoreFoundation                      0x0000000121b926ca __CFRunLoopRun + 2761
    53  CoreFoundation                      0x0000000121b91704 CFRunLoopRunSpecific + 562
    54  GraphicsServices                    0x0000000125f37c8e GSEventRunModal + 139
    55  UIKitCore                           0x000000013ab7765a -[UIApplication _run] + 928
    56  UIKitCore                           0x000000013ab7c2b5 UIApplicationMain + 101
    57  Snapask                             0x00000001045ae79f main + 63
    58  dyld                                0x0000000113195f21 start_sim + 10
    59  ???                                 0x000000020ac7151e 0x0 + 8770753822
    60  ???                                 0x000000020ac6c000 0x0 + 8770732032
)
libc++abi: terminating with uncaught exception of type NSException
Kex
  • 8,023
  • 9
  • 56
  • 129

0 Answers0