I have a basic iOS 8 app that lists the user's documents in the app's iCloud container and also in iCloud Drive.
My problem is that documents that are directly in iCloud Drive (Finder → Go → iCloud Drive) are not included as results of the metadata query. The query only returns results in the app's iCloud container's Documents
folder.
I initialize the query like this:
self.query = [NSMetadataQuery new];
self.query.searchScopes = @[NSMetadataQueryUbiquitousDataScope,
NSMetadataQueryUbiquitousDocumentsScope,
NSMetadataQueryAccessibleUbiquitousExternalDocumentsScope]; // iCloud Drive
The entitlements look like this:
<key>com.apple.developer.ubiquity-container-identifiers</key>
<array>
<string>$(TeamIdentifierPrefix)com.my.app</string>
<string>iCloud.com.my.app</string>
</array>
Even more strange: a few documents in iCloud Drive do show up sometimes, but if I move them out of iCloud Drive and back in, they do not show anymore.