UIDocumentPickerViewController custom uti for .apk file but can't work only in iOS 16.1

62 views Asked by At

I have a UIDocumentPickerViewController with the following code:

if #available(iOS 14.0, *) {
    let apkType = UTType("com.coocaa.apk")
    let docPickerVC = UIDocumentPickerViewController(forOpeningContentTypes: [apkType!])
    docPickerVC.delegate = self
    present(docPickerVC, animated: true)
} else {
    let types = ["com.coocaa.apk"]
    let docPickerVC = UIDocumentPickerViewController(documentTypes: types, in: .open)
    present(docPickerVC, animated: true)
}

I can't pick .apk file in iOS14 or iOS 16.5, But can't pick .apk files in iOS 16.1 The following screenshot shows what a .apk file looks like in the picker:
iOS file picker with APKs
I've added the following to my info.plist file which to my understanding may be needed

<key>UTExportedTypeDeclarations</key>
<key>UTExportedTypeDeclarations</key>
<array>
    <dict>
        <key>UTTypeConformsTo</key>
        <array>
            <string>public.data</string>
            <string>public.archive</string>
        </array>
        <key>UTTypeDescription</key>
        <string>apk statements</string>
        <key>UTTypeIdentifier</key>
        <string>com.coocaa.apk</string>
        <key>UTTypeTagSpecification</key>
        <dict>
            <key>public.filename-extension</key>
            <array>
                <string>apk</string>
            </array>
        </dict>
    </dict>
</array>

What do I need to do to have UIDocumentPickerViewController allow picking .apk file types in all iOS system

0

There are 0 answers