drewmccormack / ensembles

A synchronization framework for Core Data.
MIT License
1.63k stars 132 forks source link

MonitoringMetaData not working on iOS Simulator #249

Closed guidove closed 7 years ago

guidove commented 7 years ago

I'm using CDEIcloudFileSystem on XCode8.1, Swift 3 with iOS10.1 as deployment target.

I found that the iOS simulator does not recognise when updates are made on other devices.

When running my app simultaneously on 2 devices and on the iOS simulator, and do an update on one of the devices. The other device is propagated with the update, but the simulator is not.

Did some analyses and found that the metadataquery is not working properly in the simulator. Specifically NSMetadataQueryDidFinishGatheringNotification and NSMetadataQueryDidUpdateNotification are not being posted and consequently initiateDownloads is not being called and thus CDEICloudFileSystemDidDownloadFilesNotification is not being posted.

After I do a second update, this time on the simulator (on a different object, e.g. update another object or add another object), the simulator updates and I also see the first update I did on the device.

Not sure this is something that can be fixed within the Ensembles code or if this is a bug in the simulator.

Not a big deal, but if this is a simulator bug, does anyone know if this is a Mac bug? I.e. could/does this also happen for mac apps syncing with their iOS counterpart?

drewmccormack commented 7 years ago

In general, you should not rely completely on push notifications or metadata queries to trigger syncs. Sometimes they work, and sometimes they don't, or get throttled back by the system.

You should always have some sort of backup. I recommend a timer that fires every few minutes to make up for the cases when the notifs fail.

Note that the simulator does have menu items for triggering updates in iCloud.

Kind regards, Drew

On 30 Nov 2016, at 19:08, Guido notifications@github.com wrote:

I found that the iOS simulator does not recognise when updates are made on other devices.

When running my app simultaneously on 2 devices and on the iOS simulator, and do an update on one of the devices. The other device is propagated with the update, but the simulator not.

Did some analyses and found that the metadataquery is not working properly in the simulator. Specifically NSMetadataQueryDidFinishGatheringNotification and NSMetadataQueryDidUpdateNotification are not being called and consequently initiateDownloads is not being called and thus CDEICloudFileSystemDidDownloadFilesNotification is not being posted.

After I do a second update on the simulator (on a different object, e.g. update another object or add another object) the simulator updates and I also see the initial update I did on the device.

Not sure this is something that can be fixed within the Ensembles code or if this is a bug in the simulator.

I'm using CDEIcloudFileSystem on XCode8.1, Swift 3

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

guidove commented 7 years ago

That makes sense. Thanks. Added a timer and doing an ensemble.merge in the timer selector. (from the comments I assumed that a merge also includes retrieving new files from the cloud)

The timer is firing and it's merging, but don't see the update I did on the device.

When I force an iCloud sync from the simulator menu it does work.

Any thoughts?

drewmccormack commented 7 years ago

The simulator doesn't work very well with iCloud. If it works with the menu, it is working as expected.

If you want a more reliable and fast sync, you would need to move to the CloudKit backend.

Kind regards, Drew

On 30 Nov 2016, at 20:42, Guido notifications@github.com wrote:

That makes sense. Thanks. Added a timer and doing an ensemble.merge in the timer selector. (from the comments I assumed that a merge also includes retrieving new files from the cloud)

The timer is firing and it's merging, but don't see the update I did on the device.

When I force an iCloud sync from the simulator menu it does work.

Any thoughts?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.