App crash on iOS16 when presenting a QLPreviewController.

When I try to present the QLPreviewController, the app crashes, and I can see the log as shown below.

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[2]' _LSContextInitReturningError() failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xed662242 5fb7c0a8 1bf3f783 33b5c275 ... 5cef5e61 5d97a96c }, _LSLine=478, WrongSimulatorHash={length = 32, bytes = 0x3190f8e7 217931fc b7f7be3d 298bbb9a ... 8472784b 30a84b1d }} terminating with uncaught exception of type NSException CoreSimulator 857.7 - Device: iPhone 14 Pro Max (090DE6D4-3F15-4A60-ABDD-09BE30F01F89) - Runtime: iOS 16.0 (20A360) - DeviceType: iPhone 14 Pro Max

Any help would be greatly appreciated! Thanks!

Show us your code for presenting the QLPreviewController.

@darkpaw I have added the code below, Kindly check

  // MARK: - QLPreview delegate and datasource methods
  
 func numberOfPreviewItems(in controller: QLPreviewController) -> Int {
  return 1
 }
  
 func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
  let url = URL(fileURLWithPath: selectedAttachmentPath ?? "")
  return url as QLPreviewItem
 }
  
 // MARK: - custom methods

 fileprivate func presentDownloadedAttachment() {
  let previewController = QLPreviewController()
  previewController.dataSource = self
  self.present(previewController, animated: false, completion: {
   previewController.updateNavigationBarTintColor()
  })
 }

extension QLPreviewController {
  
 func updateNavigationBarTintColor() {
   
  if let firstChild = self.children[0] as? UINavigationController {
    
   let navigationBar = firstChild.navigationBar
   // The bar must be set isTranslucent = false for the tint colours to work
   navigationBar.isTranslucent = false
   navigationBar.barTintColor = AppTheme.primary.color
   navigationBar.tintColor = AppTheme.primary.color
    
   if let toolbar = firstChild.toolbar {
    // The toolbar must be set isTranslucent = false for the tint colours to work
    toolbar.isTranslucent = false
    navigationBar.barTintColor = AppTheme.primary.color
    toolbar.tintColor = AppTheme.primary.color
   }
  }
 }
}

I'm also facing this issue related to QLPreviewController.

same

App crash on iOS16 when presenting a QLPreviewController.
 
 
Q