With iOS 11, I encountered the following error every time I create a new document using the UIDocument API:
[ERROR] Could not get attribute values for item /var/mobile/Containers/Data/Application/XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX/Documents/myDoc-XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX.myFile (n). 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.}
Unlike similar questions ( 1 , 2 , 3 ) on SO, I do not use UIDocumentBrowserViewController . I just create a UIDocument and call save() in the Documents directory. the closest question I found is using a UIManagedDocument . However, in my case, the file is still being created and written successfully, despite the error message.
Here is the gist of my save routine:
@IBAction func createDoc(_ sender: Any) { let uuid = UUID().uuidString let doc = Document(baseName: "myDoc-\(uuid)") doc.save(to: doc.fileURL, for: .forCreating) { (completed) in if (completed) { doc.close(completionHandler: nil) self.verifyNumberOfFiles() } } }
The My Document subclass is also almost empty for simplicity of this question:
class Document: UIDocument { let fileExtension = "myFile" override init(fileURL url: URL) { super.init(fileURL: url) }
I always write the Documents folder, and my search procedure can verify that my files have been created successfully:
public var documentsDirectory: URL { return FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last! } func loadFileURLs(from dirURL: URL) -> [URL]? { return try? FileManager().contentsOfDirectory(at: dirURL, includingPropertiesForKeys: nil) }
What I have discovered so far:
- The error appears even when I already installed UTI. See this and this .
- I can check if my UTI works when I send "myFile" to my device via AirDrop and it correctly launches my application to open.
- The error appears only on iOS 11 . The same code does not reproduce the error on iOS 10, as in the question above .
- I tried to add the
UISupportsDocumentBrowser key, although I do not use a browser, but it does not solve the error.
What's happening? Is this just a “noise” error message on iOS 11?
Here 🔨 my GitHub code is online if anyone is interested.
ios uti ios11 document-based uidocument
Huatham
source share