question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DocumentPicker isn't allowing all file types when browsing iCloud Drive locations

See original GitHub issue

We’ve got an Expo app that we’re currently preparing for release and we use Expo DocumentPicker during the onboarding process. We’ve discovered that when browsing iCloud Drive locations only a subset of files/types are selectable. As far as I can tell we’ve setup everything correctly according to the Configuration.

The .keystore files we’re using (and some other file types eg. .sketch) our greyed out and unselectable, but only on iCloud Drive.

  • The file we’re trying to select is a JSON document using .keystore extension.
  • Everything works correctly on Android (whether using phone local locations or remote locations)
  • Everything works correctly on iPhone when picking local files or from other remote locations (eg. Google Drive)
  • We can pick other files from iCloud Drive (eg. images or PDF’s), they come into our app and the app has some logic to report that they’re invalid files.

Am I missing some required config? Is this a bug? Any help is much appreciated

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
bkboothcommented, Apr 28, 2020

Ok, I finally found the solution to this. I needed to declare the document types that our app can handle.

I really think this should be made clearer in the DocumentPicker docs. I went around in circles for a long time, and even when I thought I had it figured out, there were no concrete examples I could find anywhere of declaring document types in app.json. I basically had to map some iOS Info.plist XML examples into the app.json format.

It’s clearly not impossible to work it out, but it took a long time for me to work out and it’s definitely not friendly to newcomers.

For what it’s worth if anyone else stumbles across this, these are roughly what I ended up with in my app.json (You can search any of the keys to find the reference in the Apple docs to customise to your needs):

{
  "expo": {
    "ios": {
      "infoPlist": {
        "LSSupportsOpeningDocumentsInPlace": false,
        "CFBundleDocumentTypes": [
          {
            "CFBundleTypeName": "My Document",
            "CFBundleTypeRole": "None",
            "LSHandlerRank": "None",
            "LSItemContentTypes": [
              "com.MyOrg.MyApp.MyFiletype",
              "public.data"
            ]
          }
        ],
        "UTExportedTypeDeclarations": [
          {
            "UTTypeConformsTo": ["public.data"],
            "UTTypeDescription": "My File Type",
            "UTTypeIdentifier": "com.MyOrg.MyApp.MyFileType",
            "UTTypeTagSpecification": {
              "public.filename-extension": "myfile",
              "public.mime-type": "application/json"
            }
          }
        ]
      }
    }
  }
}
0reactions
omergcommented, May 27, 2022

@bkbooth The above sample worked perfectly on iOS, huge thanks for sharing. Have you found the equivalent solution for Android as well, so that it is possible to narrow down the available extensions instead of using */*?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Access and manage your files in iCloud Drive - Apple Support
iCloud Drive lets you securely access all of your documents from your iPhone, iPad, iPod touch, Mac, and Windows PC.
Read more >
iCloud Document Picker: App folders are disabled on import
I checked google drive's iCloud import and it's not disabled like in the image below: Google Drive iCloud import. I need to get...
Read more >
DocumentPicker - Expo Documentation
DocumentPicker. expo-document-picker provides access to the system's UI for selecting documents from the available providers on the user's device.
Read more >
react-native-document-picker - npm
A react native interface to access documents from dropbox, google drive, iCloud.... Latest version: 8.1.3, last published: a month ago.
Read more >
iCloud Drive and Document Picker for iOS 8: Explained - iMore
There are many different types of files. Text files, documents, spreadsheets, presentations, and images are all common types. The saved state of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found