drewmccormack / ensembles

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

Synchronization doesn't work on diferent devices #224

Closed garanda21 closed 7 years ago

garanda21 commented 8 years ago

I've installed the ensambles on my iOS project and every works fine, my main problem is that sync occurs only per device, if I install my application on other devices doesn't sync the data of the first device it creates its own store in the iCloud documents, and that happen for every device with the same app and same iCloud account.

They didn't share the same iCloud db, every single device creates its own, and all devices has the same iCloud account.

drewmccormack commented 8 years ago

That sounds normal.

Are you properly merging the changes using the delegate methods? Do you refresh you UI when the changes merge?

You have to all the mergeWithCompletion: method to get new changes from the other devices.

Drew

On 08 Apr 2016, at 08:33, garanda21 notifications@github.com wrote:

I've installed the ensambles on my iOS project and every works fine, my main problem is that sync occurs only per device, if I install my application on other devices doesn't sync the data of the first device it creates its own store in the iCloud documents, and that happen for every device with the same app and same iCloud account.

They didn't share the same iCloud db, every single device creates its own, and all devices has the same iCloud account.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/drewmccormack/ensembles/issues/224

garanda21 commented 8 years ago

I'm actually using this swift example : https://github.com/oskarirauta/EnsembleExample, it call the method syncWithCompletionon every save and when the app starts, inside this method theres a mergeWithCompletion so yes I'm using it. Any thoughts?

drewmccormack commented 8 years ago

So it will only pull down data if you save data locally, or launch the app? Doesn't sound like very often. What if you make no changes locally? Then you won't get any new data from other devices.

Something else to check: how are you using global identifiers?

kajensen commented 8 years ago

@garanda21 did you figure this out? I'm in the same exact position (used same sample project) trying to sync between osx and ios

garanda21 commented 8 years ago

@kajensen no yet, I've made some tests and it also happens with the obj c example Simple Sync from this repository.

By the way @drewmccormack I'm using iOS 9.3 on all my devices maybe some issue related was the the latest iOS version? Structure from iCloud may change on this version?

JDSX commented 8 years ago

It seems I have the same issue, when you guys remove the app and reinstall does the app use the iCloud backup or start from new ?

I have used all the example apps and the following https://www.dropbox.com/s/qflbtokbe24noy8/Simple%20Sync%20in%20Swift.zip?dl=0 but cannot get anything to sync between devices.

I get no errors, in the log it shows the app has leeched, merged and refreshed the UI, but no new data is shown from other devices and neither does the app use the data from iCloud when reinstalled.

drewmccormack commented 8 years ago

Receiving any errors?

You need to make sure you register your app for iCloud on the developer site:

If you use this, it may give more info:

CDESetLoggingLevel(CDELoggingLevelVerbose);

Post any errors.

Kind regards, Drew

On 08 Apr 2016, at 22:44, Kurt notifications@github.com wrote:

@garanda21 did you figure this out? I'm in the same exact position (used same sample project) trying to sync between osx and ios

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

garanda21 commented 8 years ago

Very helpful the command: CDESetCurrentLoggingLevel(CDELoggingLevel.Verbose.rawValue), with this I was able to see the entire workflow, from creation remote directories to merge information. After that and comparing and monitoring all the .cdeevent files, first I delete all the files from the directory: ~/Library/Mobile Documents/[app name] and made a few changes on the code, everything seem to work fine now.

For those who need some help I create a new repository with all the changes here: https://github.com/garanda21/EnsembleSwift with this example it creates a few records and sync with all other devices using same iCloud account, tested on iPhone 6s+ and iPad mini 2. (abstain to make tests in the simulator with real devices because it doesn't works).

Thanks @drewmccormack for your support was very helpful.

Kind regards, Gio.

JDSX commented 8 years ago

Yep you was right, I got my hands on a second device at it works pretty great. Haven't experienced any bugs atm. I am unsure why it didn't work on the simulator. Thanks @drewmccormack for your support.

drewmccormack commented 8 years ago

There is a menu in the simulator to force an iCloud sync. Maybe that can help.

Kind regards, Drew

On 09 Apr 2016, at 16:17, jsingh notifications@github.com wrote:

Yep you was right, I got my hands on a second device at it works pretty great. Haven't experienced any bugs atm. I am unsure why it didn't work on the simulator. Thanks @drewmccormack for your support.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub

garanda21 commented 8 years ago

@drewmccormack One last question, do you know if exists a master switch to use or not the iCloud Sync, I want to create an iCloud setting in my app, and if this is off ensembles must also be turned off.

drewmccormack commented 8 years ago

No quite sure what you mean.

You can check if iCloud is turned on by using NSFileManager and the ubiquityIdentityToken method of that.

You can always build a switch into your app to turn off Ensembles. If it is off, deleech, and if it is turned on, leech and merge.

Drew

On 12 Apr 2016, at 14:00, garanda21 notifications@github.com wrote:

@drewmccormack https://github.com/drewmccormack One last question, do you know if exists a master switch to use or not the iCloud Sync, I want to create an iCloud setting in my app, and if this is off ensembles must also be turned off.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/drewmccormack/ensembles/issues/224#issuecomment-208866311

garanda21 commented 8 years ago

Yes I want the second one, build a switch to turn off Ensembles. I'm not quite sure how to deleech, I've to call a method for this?

drewmccormack commented 8 years ago

Yes. deleechWithCompletion: See the book at http://leanpub.com/ensembles

On 12 Apr 2016, at 14:13, garanda21 notifications@github.com wrote:

Yes I want the second one, build a switch to turn off Ensembles. I'm not quite sure how to deleech, I've to call a method for this?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/drewmccormack/ensembles/issues/224#issuecomment-208874483

kajensen commented 8 years ago

I'm still having issues syncing OSX and iOS. iOS to iOS works fine. The OSX app has a different bundleID (it has to be unique from any iOS/OSX), but that doesn't matter because I specify the same container (for both) in the entitlements as well as the CDEICloudFileSystem(ubiquityContainerIdentifier:) initializer. In fact, I'm sharing the same CoreDataStack.swift file (handles core data/ensembles initialization, merging, saves, etc) between apps. I can post it if that will help. Not sure where i'm going wrong. It is possible to sync between OSX and iOS, correct?

drewmccormack commented 8 years ago

It is absolutely possible.

Try turning on the ensembles logging to see what is going wrong.

CDESetCurrentLogLevel(CDELoggingLevelVerbose);

Kind regards, Drew

On 19 Apr 2016, at 21:39, Kurt notifications@github.com wrote:

I'm still having issues syncing OSX and iOS. iOS to iOS works fine. The OSX app has a different bundleID (it has to be unique from any iOS/OSX), but that doesn't matter because I specify the same container (for both) in the entitlements as well as the CDEICloudFileSystem(ubiquityContainerIdentifier:) initializer. In fact, I'm sharing the same CoreDataStack.swift file (handles core data/ensembles initialization, merging, saves, etc) between apps. I can post it if that will help. Not sure where i'm going wrong. It is possible to sync between OSX and iOS, correct?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub

kajensen commented 8 years ago

Ok i'm using CDESetCurrentLogLevel(CDELoggingLevelVerbose); I can see the OSX store/events/data being created in the console and also in my iCloud drive (~/Library/Mobile Documents). I don't see any iOS ensembles data showing up here. Including example projects. Shouldn't both show up there or am I misunderstanding? Everything syncs fine between iOS devices and I can track iOS store/events/data in the console

drewmccormack commented 8 years ago

Yes, iOS data should appear there. I assume you are using the same backend for both platforms. You aren't accidentally using iCloud Drive for one, and CloudKit for the other?

So both devices show log messages indicating they are syncing?

Look carefully in Mobile Docs and see if there are other folders that could be from your app. Maybe they are using different folders after all.

Kind regards, Drew

On 20 Apr 2016, at 01:18, Kurt notifications@github.com wrote:

Ok i'm using CDESetCurrentLogLevel(CDELoggingLevelVerbose); I can see the OSX store/events/data being created in the console and also in my iCloud drive (~/Library/Mobile Documents). I don't see any iOS ensembles data showing up here. Including example projects. Shouldn't both show up there or am I misunderstanding? Everything syncs fine between iOS devices and I can track iOS store/events/data in the console

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub

kajensen commented 8 years ago

I had both iCloud Drive and CloudKit enabled (as well as key-value storage). Disabling cloudkit for both doesn't seem to change anything. Yeah both show log messages indicating they're syncing. I can verify on multiple iOS devices that syncing between works. Can't verify OSX because I only have one mac but I can view its data changes in Mobile Docs. There aren't any other folders that are created that could be from my app.

Is there a way to determine if ensembles is using cloudkit vs icloud drive?

drewmccormack commented 8 years ago

The iOS data should also be appearing in Mobile Documents, otherwise something is very odd indeed.

You are using iCloud Drive if you have the CDEICloudFileSystem. If you use the CDECloudKitFileSystem, you have cloud kit.

My guess is that the iOS devices are using a different ubiquity container. I assume you have registered the ubiquity containers in the provisioning portal on Apple’s web site, right? Both apps should be using a ubiquity id something like

iCloud.com.mycompany.myapp

Drew

On 20 Apr 2016, at 15:17, Kurt notifications@github.com wrote:

I had both iCloud Drive and CloudKit enabled (as well as key-value storage). Disabling cloudkit for both doesn't seem to change anything. Yeah both show log messages indicating they're syncing. I can verify on multiple iOS devices that syncing between works. Can't verify OSX because I only have one mac but I can view its data changes in Mobile Docs. There aren't any other folders that are created that could be from my app.

Is there a way to determine if ensembles is using cloudkit vs icloud drive?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/drewmccormack/ensembles/issues/224#issuecomment-212420064

drewmccormack commented 8 years ago

BTW there is are iOS and Mac versions of the sample app Idiomatic, both using iCloud. You could see how it is being done there.

Drew

On 20 Apr 2016, at 15:17, Kurt notifications@github.com wrote:

I had both iCloud Drive and CloudKit enabled (as well as key-value storage). Disabling cloudkit for both doesn't seem to change anything. Yeah both show log messages indicating they're syncing. I can verify on multiple iOS devices that syncing between works. Can't verify OSX because I only have one mac but I can view its data changes in Mobile Docs. There aren't any other folders that are created that could be from my app.

Is there a way to determine if ensembles is using cloudkit vs icloud drive?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/drewmccormack/ensembles/issues/224#issuecomment-212420064

kajensen commented 8 years ago

Yeah sorry that was a dumb question. I'm using CDEICloudFileSystem for both. Both apps use the same code to initialize the core data stack + ensembles, which specifies the same ubiquity container, which is setup correctly for the provisioning and in entitlements. I will checkout the sample apps, thanks.

drewmccormack commented 8 years ago

If you go into the Mobile Documents, you should see ‘events’ files from multiple devices (different UUIDs). Go into that events file, make a change on iOS, save the change, sync, and then see if any new files come into Mobile Documents in the next few minutes.

If that is working OK, the problem might be that you are not merging the sync changes into your context properly on the Mac. You have to implement the delegate methods right, and you need to call the mergeWithCompletion: method, or nothing will happen.

Drew

On 20 Apr 2016, at 15:33, Kurt notifications@github.com wrote:

Yeah sorry that was a dumb question. I'm using CDEICloudFileSystem for both. Both apps use the same code to initialize the core data stack + ensembles, which specifies the same ubiquity container, which is setup correctly for the provisioning and in entitlements. I will checkout the sample apps, thanks.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/drewmccormack/ensembles/issues/224#issuecomment-212425500

kajensen commented 8 years ago

Experiencing the same thing with Idiomatic. Everything appears to sync in the console, but only OSX data shows up in Mobile Docs. Its almost as if it thinks its a different iCloud account, but I'm certain it is the same account logged in on all devices.

kajensen commented 8 years ago

logging into a different account on both devices has fixed the problem. Odd.

Thanks so much for your help! Awesome library

drewmccormack commented 8 years ago

That is really odd. I don’t know how I can really help. This is not so much an Ensembles problem but a general iCloud Drive issue. Maybe you can do a bit of online searching for that.

If your iOS devices are syncing, they must be uploading data. How that data would not end up on the Mac, I don’t know. In any case, if you do have the same iCloud account, that data must end up somewhere in Mobile Documents. All your iCloud Drive data must.

So maybe do some searching about iCloud Drive not syncing data between devices. (Does it work for other apps, by the way?)

Drew

On 20 Apr 2016, at 16:04, Kurt notifications@github.com wrote:

Experiencing the same thing with Idiomatic. Everything appears to sync in the console, but only OSX data shows up in Mobile Docs. Its almost as if it thinks its a different iCloud account, but I'm certain it is the same account logged in on all devices.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/drewmccormack/ensembles/issues/224#issuecomment-212439494

drewmccormack commented 8 years ago

Ah, good to know.

Drew

On 20 Apr 2016, at 16:13, Kurt notifications@github.com wrote:

logging into a different account on both devices has fixed the problem. Odd.

Thanks so much for your help! Awesome library

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/drewmccormack/ensembles/issues/224#issuecomment-212442440