10

Update: Xcode 9.3 has fixed it.


When creating UIDocument File in UIDocumentBrowserViewController

enter image description here

[default] [ERROR] Could not resolve bookmark. Error: Error Domain=NSFileProviderInternalErrorDomain Code=1 "The reader is not permitted to access the URL." UserInfo={NSLocalizedDescription=The reader is not permitted to access the URL.}

[DocumentManager] Failed to create a url from bookmarkableString (Error Domain=NSFileProviderInternalErrorDomain Code=1 "The reader is not permitted to access the URL." UserInfo={NSLocalizedDescription=The reader is not permitted to access the URL.})

Code work well in Xcode 9.1, But Failed in Xcode 9.2. almost the same code as wwdc 2017.

func documentBrowser(_ controller: UIDocumentBrowserViewController, didRequestDocumentCreationWithHandler importHandler: @escaping (URL?, UIDocumentBrowserViewController.ImportMode) -> Void) {
    let newDocumentURL: URL? = R.file.templateDocument()

    // 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 {
        importHandler(newDocumentURL, .copy)
    } else {
        importHandler(nil, .none)
    }
}

enter image description here

Community
  • 1
  • 1
hstdt
  • 5,652
  • 2
  • 34
  • 34
  • 4
    Same problem here. The document browser has always been broken on the simulator, but now it is 100% useless. It works fine on real devices, though. – Bruno Philipe Dec 11 '17 at 12:18
  • So sad it is not working on my simulator. I have to try it on real device. – Michał Ziobro Feb 02 '18 at 13:50
  • Is the question about `didPick` or `didRequestDocumentCreation`? Your didPick code is wrong, you need to call `startAccessingSecurityScopedResource` on the URL to consume the sandbox extension given to you by the doc browser. Don't forget to call stopAccessing once you are done with the document. – Thomas Deniau Apr 11 '18 at 15:58
  • @ThomasDeniau Xcode 9.3 has fixed this problem. – hstdt Apr 25 '18 at 08:31

0 Answers0