4

I'm trying to import a ZIP file via the built-in 'Open With...' function.

Here's what I have added to my Info.plist file:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>ZIP Archive</string>
        <key>CFBundleTypeIconFile</key>
        <string>zip</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>CFBundleTypeOSTypes</key>
        <array>
            <string>ZIP </string>
        </array>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>zip</string>
        </array>
        <key>CFBundleTypeMIMETypes</key>
        <array>
            <string>application/zip</string>
            <string>application/x-zip</string>
            <string>application/x-zip-compressed</string>
        </array>
    </dict>
</array>

However, my app is not appearing when the 'Open With...' view is launched. Why is this?

James Anderson
  • 556
  • 3
  • 16
  • 41

2 Answers2

14

Your problem is that you've failed to declare the relevant uniform type identifier (UTI). For many file types you need to either import or export a UTI; for zip files you needn't bother because it's on the list of UTIs that the system inherently recognises.

So it should be sufficient simply to add the following to your document type:

<key>LSItemContentTypes</key>
<array>
    <string>com.pkware.zip-archive</string>
</array>
Tommy
  • 99,986
  • 12
  • 185
  • 204
  • If I could upvote this answer a 1000 times I would. Spent all day on this! You "simply" need to know that Apple expects you to find your needle in their vast supply of haystacks. Many other "answers" said to just add "zip" to the content type. That, of course, was not working and I was beginning to believe this was yet another iOS 13 bug. Thank you Tommy! – WholeCheese Nov 23 '19 at 23:43
1

Expanding on @Tommy's answer you can add this value using Xcode in your project as shown:

Xcode Info settings

Gerry Shaw
  • 9,178
  • 5
  • 41
  • 45