DocumentPickerViewController in move or export mode rejected with nonexistent url (create document provider app extension)

I am currently trying to implement functionality for move and export modes. All I do is navigate the user to the directory they want to move / export their file to, then call rejectGrantingAccessToURL on the directory they choose with the filename of the original file. This is how it looks in code:

let moveDestinationPath = self.currentDirectory.path.stringByAppendingPathComponent(AppHelper.Stored.originalURL!.lastPathComponent)
delegate.finishWithURL(NSURL.fileURLWithPath(moveDestinationPath))

      

I thought this was enough given that the documentation says the following:

Export of the document selection mode. Enter the URL for the selected recipient. This URL should only be accessible by the Document Controller Extension. The system saves a copy of the document at this URL and returns the URL of the host application to indicate success. The host application cannot access the document at this URL.

Move document selection mode. Enter the URL for the selected recipient. The url must be contained within the hierarchy specified by your documentStorageURL property. The system moves the document to this URL and returns the URL of the host application. The host application can then access the document at the new URL.

However, when I run this code, I get the following error:

Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: '<TestDocumentProvider.DocumentPickerViewController: 0x7c470770> was 
dismissed with a nonexistent URL (file:///Users/test/Library/Developer/CoreSimulator
/Devices/6867B1A7-8694-4D6D-8480-69FE89F39C27/data/Containers/Shared/AppGroup/74A2FBED-
70C5-4F24-8345-AD35FEB86D01/FileProviderStorage/Directory1/apple1.png) 
in Move or Export mode'

      

Given this error, it seems that they want me to manually move or copy the file to the original URL by myself. But this is contrary to what the documentation says (the part about system operation).

So, does anyone know what Apple intends to do in this situation? For now, I'll probably just go down the move / copy path myself ...

+3


source to share


1 answer


I think you are misunderstanding the export mode. The goal is for someone to pick a file that your extension can connect to. You download / provide it and present the FileURL to the requesting application.



What you really want to do is import mode.

+2


source







All Articles