Just to clear up a few quick items first:
- I do not want to open and/or preview the document, as I see a common answer referring users to a dependency for doing that
- I do not want to select any other file type. My app specifically wants to take a powerpoint document and then pass it to an API call
With that said, I have been unable to get my picker to allow me to open a PPTX as seen here:
I have taken the following actions to try and resolve this:
I ran mdls -name kMDItemContentTypeTree test.pptx
against the file to obtain its content type.
kMDItemContentTypeTree = (
"org.openxmlformats.presentationml.presentation",
"public.data",
"public.composite-content",
"public.archive",
"public.item",
"org.openxmlformats.presentationml.presentation",
"org.openxmlformats.openxml",
"public.zip-archive",
"public.presentation",
"public.content",
"com.pkware.zip-archive" )
Which I then added to my info.plist file as seen here:
<dict>
<key>LSItemContentTypes</key>
<array>
<string>org.openxmlformats.presentationml.presentation</string>
<string>public.data</string>
<string>public.composite-content</string>
<string>public.archive</string>
<string>public.item</string>
<string>org.openxmlformats.presentationml.presentation</string>
<string>org.openxmlformats.openxml</string>
<string>public.zip-archive</string>
<string>public.presentation</string>
<string>public.content</string>
<string>com.pkware.zip-archive</string>
</array>
<key>CFBundleTypeName</key>
<string>PPTX</string>
<key>LSHandlerRank</key>
<string>Alternate</string>
</dict>
Then, I referenced this Apple site to get the UTI for powerpoint.
com.microsoft.powerpoint.ppt
Finally, I set up my call like this:
let powerpointType = "com.microsoft.powerpoint.ppt"
let documentPicker = UIDocumentPickerViewController(documentTypes: [powerpointType],
in: .import)
But, as seen in the initial image, this does not allow me to select the file. Thus, I am hoping to find the missing piece to allow for the selection of just powerpoint files.
** UPDATE ** Based on matt's comment, I did add the value to my plist and was still unable to select the file.
I additionally tested using a pptx
extension in the plist & UIDocumentPickerViewController
call with no success either.