Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwiftUI Example (I'm working on it) #207

Open
bofrese opened this issue Jul 10, 2020 · 2 comments
Open

SwiftUI Example (I'm working on it) #207

bofrese opened this issue Jul 10, 2020 · 2 comments

Comments

@bofrese
Copy link
Contributor

bofrese commented Jul 10, 2020

I needed a more complete example on how SwiftUI + Realm + IceCream all works together, and a simple app to experiment on, rather than my "real'' app.
I file this issues, mostly to let you know that I'm already working on it, and making good progress. I'll push it to my github fork soon, so you can have a preview, and make a pull request when I think it's ready.

Design goals:

  • Few dependencies. Ideally only Realm and IceCream - to keep it simple.
  • A useful simple playground to use as base for experimentation, stress testing, hunting down bugs, error handling etc. rather than using your complex real life app for that.
  • A more 'complete' example, that allows you to see how it all works together. Possibly to serve as a 'blueprint' on a SwiftUI + Realm + IceCream app (The SwiftUI example from Realm uses Lists, which is not supported by IceCream, and Results are not an ObservableObject. Besides the SwiftUI.List / ForEach need to operate on a frozen Realm results to not crash when changing the model. etc., etc.....)

I'll do this anyway, but do you want this added as another example to the IceCream repo?
Any other requests, needs, etc.?

Regards,
Bo

@bofrese
Copy link
Contributor Author

bofrese commented Jul 22, 2020

I have created a first version of the SwitUI example. You can see it at https://github.com/bofrese/IceCream/tree/swiftui_example/SwiftUIExample
and I have also created a pull request for this.

The Example app includes some 'stress testing' tools, to quickly add 10 or 100 people+cats to realm.
My experience so far is that is is to easy to get errors in the IceCream/CloudKit layer, which the app never recovers from, leaving the data out of sync between devices. This especially happens when inserting many records at a time.
Some records are simply never synchronised. I have yet to discover a way to catch these errors, and to find a way to recover from them. I have studied the existing example app, and can not see that it should be anything in my Example app, so currently I suspect bugs in IceCream.
However, it is my impression that a lot of people are using IceCream for production apps(?), and I can not believe they would be doing that, if it was this easy to get data out of sync. So I'm probably overlooking something......??

So if anybody would like to try out the new SwiftUIExample App, stress test it a bit, and review the code, I would much appreciated it.

@riverbaymark
Copy link

Hi @bofrese and thanks for all your work on this. I'm new to IceCream so still learning, but love what it brings. I think I may know what the deal is with the data falling out of sync. I cannot tell you how many hours I have chased data that depends on @observableobject. Things fall out of scope all the time. I'm going to try your solution and replace @observableobject with @StateObject where applicable. This is iOS14 only but keeps things in sync (like ObservableObject was supposed to but fails to do).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants