Saik0s / Whisperboard

The open-source iOS app that's making quality voice transcription more accessible on mobile devices.
GNU General Public License v3.0
684 stars 72 forks source link

Passing argument of non-sendable type 'NSItemProvider' outside of main actor-isolated context may introduce data races #30

Closed sheng-di closed 5 months ago

sheng-di commented 6 months ago
func processInputItems(extensionContext: NSExtensionContext) async {
    do {
      try setupSharedContainer()

      let itemsAttachments = extensionContext.inputItems
        .compactMap { $0 as? NSExtensionItem }
        .compactMap(\.attachments)
        .flatMap { $0 }

      for itemProvider in itemsAttachments where itemProvider.hasItemConformingToTypeIdentifier(UTType.url.identifier) {
        let data = try await itemProvider.loadItem(forTypeIdentifier: UTType.url.identifier, options: nil)
        if let data = data as? URL {
          try await handleLoadedData(data)
        } else {
          throw ShareError.somethingWentWrong
        }
      }
      state = .success
    } catch {
      print("\(#filePath):\(#line)", error.localizedDescription)
      presentErrorAlert(for: ShareError.somethingWentWrong)
    }
  }

At let data = try await itemProvider.loadItem(...), there is an error:

/Whisperboard/App/ShareExtension/ShareViewController.swift:237:30 Passing argument of non-sendable type 'NSItemProvider' outside of main actor-isolated context may introduce data races
megeek commented 5 months ago

I get the same error when trying to compile