簡體   English   中英

iOS13模擬器上的UIDocumentBrowserViewController錯誤“無法為URL創建urlWrapper”

[英]UIDocumentBrowserViewController error “Cannot create urlWrapper for url” on iOS13 simulator

在iOS 13上進行測試時, UIDocumentBrowserViewController存在一個非常奇怪的問題importHandler(newDocumentURL, .move)似乎importHandler(newDocumentURL, .move)地崩潰:

[DocumentManager] Cannot create urlWrapper for url file:///.../tmp/23720D22-BC1D-4E7B-A7AE-A1C8B0293F9E.txt. 
error Error Domain=NSPOSIXErrorDomain Code=22 "couldn't issue sandbox extension com.apple.app-sandbox.read-write for '/.../tmp/23720D22-BC1D-4E7B-A7AE-A1C8B0293F9E.txt': 
Invalid argument" UserInfo={NSDescription=couldn't issue sandbox extension com.apple.app-sandbox.read-write for '/.../tmp/23720D22-BC1D-4E7B-A7AE-A1C8B0293F9E.txt': Invalid argument}.

這是一個復制的兩步過程:

  • 創建一個新的Xcode項目“基於文檔的應用程序”
  • documentBrowser(_: , didRequestDocumentCreationWithHandler:)中輸入以下代碼

     let newDocumentURL: URL? = URL(fileURLWithPath: NSTemporaryDirectory()) .appendingPathComponent(UUID().uuidString) .appendingPathExtension("txt") // Set the URL for the new document here. Optionally, you can present a template chooser before calling the importHandler. // Make sure the importHandler is always called, even if the user cancels the creation request. if newDocumentURL != nil { print(newDocumentURL!) try! "My file content".write(to: newDocumentURL!, atomically: true, encoding: .utf8) importHandler(newDocumentURL, .move) } else { importHandler(nil, .none) } 

在iOS 13模擬器上啟動它,創建一個新文檔,錯誤被打印出來,其他任何事情都沒有發生。

如果您在iOS 12上執行相同的代碼,則可以完美運行,該文件將被移動並由應用打開。

該問題發生在iOS 13 beta 7上,無論它是由Xcode 11 beta 7還是Xcode 10.3編譯的

任何的想法?

編輯 :當您在文檔目錄而不是臨時目錄中創建文件時,仍然會出現問題:

FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]

編輯2 :Xcode 11 GM(11A419c)仍然存在問題

編輯3 :問題僅存在於模擬器。 在具有iOS 13 GM的設備上, UIDocumentBrowserViewController可以正常工作。

編輯4 :問題仍然存在於帶有官方Xcode 11版本11A420a(又名GM種子2)的模擬器上。

編輯5 :問題僅發生在莫哈韋沙漠上,並且在卡塔琳娜州似乎不存在

我已驗證該錯誤與Mac OS Mojave上運行的Xcode 11.1 GM存在。

在Catalina Beta 9上運行時,不會發生此問題。(FWIW我在Parallels虛擬機中運行了Catalina Beta 9,因為我不知道它是否足夠穩定以升級到用於生產工作。)

尋找解決方法,如果有發現,將發布(但請注意,這不是我的專業領域,只是憑直覺就證明是正確的。)

您可能需要更新您提交的Radar,以表明這可能特定於Mojave。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM