3

I'm currently trying to implement functionality for Move and Export Modes. All I do is have the user navigate to the directory they want to move/export their file to, then call dismissGrantingAccessToURL on the the directory they choose, with the filename of the original file appended. Here's how it looks in code:

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

I thought that this should suffice, given that the documentation says the following:

Export Document Picker mode. Provide a URL for the selected destination. This URL needs to be accessible only by the Document Picker View Controller extension. The system saves a copy of the document at this URL and returns the URL to the host app to indicate success. The host app cannot access the document at this URL.

Move Document Picker mode. Provide a URL for the selected destination. The URL needs to be contained inside the hierarchy referred to by your documentStorageURL property. The system moves the document to this URL and returns the URL to the host app. The host app 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 appears that they want me to manually move or copy the file at the original URL over myself. But this contradicts what the documentation says (the part about the system doing it).

So, anyone have any idea what Apple intends for me to do in this situation? For now I'll probably just go the route of doing the moving/copying myself...

Community
  • 1
  • 1
arcticmatt
  • 1,956
  • 1
  • 19
  • 36

1 Answers1

2

I think you misunderstand Export Mode. The target is, that someone selects a file that your extension can reach. You download/provide it and present the FileURL to the requesting App.

What you really want to do is Import Mode.

Kevin Griesbach
  • 668
  • 7
  • 19