Hi all,
I’m building an iOS app where I need to determine user picked files or folders using UIDocumentPickerViewController, whether the selected item is synced or managed by a cloud storage provider such as:
- Google Drive
- iCloud Drive
- OneDrive
- Dropbox
- or any third-party File Provider extension
My intent is to detect this and optionally warn the user that the item may be subject to syncing behavior.
So far, I’ve tried a few different approaches:
-
Extended Attributes (listxattr / getxattr) While this does not give reliable outcome.
-
Heuristically search for keywords like 'Drive', 'GoogleDrive' etc But this is also not reliable.
Question
Is there any possible reliable and documented way to detect programmatically if a file/folder is cloud-synced or managed by a File Provider from within a regular iOS app (not an extension), especially for:
- Google Drive
- OneDrive
- Dropbox
- iCloud
- Other third-party providers?
Also, is there any recommended fallback strategy for iOS versions prior to 17 where NSFileProviderManager
may have limitations?
Any input from Apple engineers or those who have tackled this would be hugely appreciated!
Thanks in advance 🙌
Is there any possible reliable and documented way to detect programmatically if a file/folder is cloud-synced or managed by a File Provider from within a regular iOS app (not an extension), especially for:
Yes, I think so. Two keys in particular:
-
NSURLIsUbiquitousItemKey-> This means an object is under the "control" of iCloud Drive or a File Provider.
-
NSURLUbiquitousItemIsExcludedFromSyncKey-> This tells you if the object has been excluded from syncing by iCloud Drive or a File Provider.
However, I will warn the that the word "reliable" is tricky here. Fundamentally, when your opening objects that your app doesn't control... your app doesn't have control over those objects. There are nearly endless edge cases here and this only covers one specific (though obviously common) case.
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware