Search code examples
swiftios11xcode9uidocumentbrowservc

UIDocumentBrowserViewController bug with UTIs


I created an app for iOS 11 with an UIDocumentViewController (From the Xcode 9 template). I registered document types to support .swift files (public.swift-script) and it’s working with open in place and Files app, but in the app’s browser, files with .swift extension are disabled and I can’t select them.

I don’t know if is an iOS 11 bug or me because it’s work if I set document types to work with public.item files.

NOTE: The same thing happens if I allow to pick multiple items, but if I click ‘Select All’, files are selected normally.


Solution

  • I may not have all the information I need, but using the template and my understanding of your question all I needed to do was add the UTI to the Info.plist like this:

    Via Source

    <key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeIconFiles</key>
            <array/>
            <key>CFBundleTypeName</key>
            <string>Source Code</string>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>LSHandlerRank</key>
            <string>Alternate</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>public.swift-source</string>
            </array>
        </dict>
        <dict/>
    </array>
    

    Via the GUI

    If I misunderstood your question, let me know.