1

I am working on document provider extension for import mode.

URL of file is sitting inside the shared container shared by both extension & container app.

I got assertion failure saying that it should sit inside shared container/File Provider Storage directory.

So I copied file from original directory to File Provider Storage directory.

I have a file in original location & I got a file in new copied location also. I checked for data length of the file also, Its proper ,

But when I call [self dismissGrantingAccessToURL:toUrl];

Its not dismissing UIDocumentPickerExtensionViewController,

I am not facing any exceptions , but it wont dismiss and initiate the transfer, So user can still access the extension.

Below is my code, If anyone came across the same thing please leave your reply.

- (void)userChoosesEntityOfUrl:(NSURL *)url
{
    NSURL *toUrl = [self.documentStorageURL URLByAppendingPathComponent:[url lastPathComponent]];

    if ([[NSFileManager defaultManager] fileExistsAtPath:[toUrl path]]) {
        [[NSFileManager defaultManager] removeItemAtPath:[toUrl path] error:nil];
    }
    if ([[NSFileManager defaultManager] copyItemAtURL:url toURL:toUrl error:nil]) {

        NSLog(@"%@", [toUrl path]);
    }
    if (![[NSFileManager defaultManager] fileExistsAtPath:[toUrl path]]) {
        NSLog(@"File Doesn't exists at this path");
        return;
    }
    NSLog(@"Data Length %i",[[NSData dataWithContentsOfFile:[toUrl path]] length]);

    [self dismissGrantingAccessToURL:toUrl];
}
Ilanchezhian
  • 17,426
  • 1
  • 53
  • 55
Vijay
  • 31
  • 4

2 Answers2

2

When debugging your implementation of NSFileProviderExtension, you usually end up stopping/killing it using Xcode. After this, iOS often has problems restarting your file extension. This results in your document picker not being dismissed after calling dismissGrantingAccessToURL:. This bug also affects your subclass of UIDocumentPickerExtensionViewController which sometimes won't start (you only see the navigation bar of the document picker but not the content).

The workaround is to reboot your device.

davidisdk
  • 3,358
  • 23
  • 12
0

This will occur if you have a backing File Provider extension that has not been fully implemented. Remove the File Provider target from your embedded extension phase, set your document extension only support import/export modes in the Info.plist, and do a product -> Clean before building and running your extension.

Andrew Theis
  • 933
  • 7
  • 15
  • This is not changing anything for me ... Note that I also have the exact same issue with the "NewBox" sample app ! – Sylverb Oct 14 '14 at 18:41
  • I've created my project again, and when I've added the "Document provider" target, I've unchecked the "Include a File Provider extension" checkbox. I don't know if it's related to that, but now it's working ! – Sylverb Oct 30 '14 at 10:07