I am trying to set UIDocumentPickerViewController
to only allow selection of files with .sqlite extension with a dynamic UTI. I don't want to define this as a document type for my app since I cannot handle any sqlite file, I just want to enable backup and transfer with iCloud drive.
NSString *typeForExt = (__bridge NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, CFSTR("sqlite"), kUTTypeItem);
UIDocumentPickerViewController *iCloudPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[typeForExt] inMode:UIDocumentPickerModeImport];
UIDocumentPickerViewController
will allow selection of sqlite files if I define the type as the generic public.item but then every file is an option.
The proper solution is to define the sqlite UTI in the "Imported UTIs" section of your Info.plist. This doesn't declare that your app can work with an sqlite file. It just declares the UTI.
In Xcode, select your target. Select the Info tab. Go down to the Imported UTIs section and add the definition for sqlite.