didPickDocumentsAtURLs delegate is not getting called for UIDocumentPickerViewController

I am trying to use UIDocumentPickerViewController and need to target the app for iOS 11.0 and above. I am testing in simulator for iOS version 11.0, 12.0 and 13.4

The delegate method didPickDocumentsAtURLs in not called (for local files) on 11.0 and 12.0 however it is called on 13.4 version of iOS. The documentPickerWasCancelled is called in all cases. The delegate is called on iOS 11.0 and 12.0 if picking iCloud drive though.


Here is a smallest code that can reproduce the issue. I have a main view with only one button and button tap handler is defined below.



#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {

[super viewDidLoad];

}

- (void)documentPicker:(UIDocumentPickerViewController *)controller

didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls {

}

- (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller {

}

- (IBAction)buttonTapped:(id)sender {

UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.data"] inMode:UIDocumentPickerModeImport];

documentPicker.delegate = self;

[self presentViewController:documentPicker animated:YES completion:nil];

}

@end