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 Previews + Device Sync: Make It Less Painful? #8528

Closed
bdkjones opened this issue Mar 24, 2024 · 2 comments
Closed

SwiftUI Previews + Device Sync: Make It Less Painful? #8528

bdkjones opened this issue Mar 24, 2024 · 2 comments
Assignees
Labels
Importance:Major O-Community SDK-Use:Sync T-Enhancement Waiting-For-Reporter Waiting for more information from the reporter before we can proceed

Comments

@bdkjones
Copy link

Problem

I have an app that uses Realm and Atlas Device Sync. If I add a SwiftUI view and allow Xcode to show me a preview of it, Xcode has to invisibly build and run the entire app (regardless of whether anything in the SwiftUI view depends on anything else in the app).

The trouble is that the next time I hit the "play" button in Xcode to actually build and run the app, it immediately crashes with a "multiple sync clients connected" exception. Because the SwiftUI preview version is still running.

Closing the preview canvas or switching away from it by selecting a different file does not solve the issue. The only reliable solution is to quit and relaunch Xcode. This is painful.

Apple is unlikely to ever solve this. They don't care about people using Realm. Is there anything that can be done from Realm's side to make SwiftUI previews more friendly?

Solution

The ideal solution is that a true build-and-run of the app (from the user clicking the play button in Xcode) "overrides" any other running version of the binary from the SwiftUI preview. Functionally, I imagine that's difficult.

Alternatives

No response

How important is this improvement for you?

Would be a major improvement

Feature would mainly be used with

Atlas Device Sync

Copy link

sync-by-unito bot commented Mar 24, 2024

➤ PM Bot commented:

Jira ticket: RCOCOA-2321

@nirinchev
Copy link
Member

We have a project in progress to allow multiple processes to access the same Realm file, that should make this go away. In the meantime, what you could do is change the path where the Realm file is stored based on the value of the XCODE_RUNNING_FOR_PREVIEWS environment variable. You could modify the path of the Realm file by setting Configuration.fileUrl.

@nirinchev nirinchev self-assigned this Mar 24, 2024
@sync-by-unito sync-by-unito bot added the Waiting-For-Reporter Waiting for more information from the reporter before we can proceed label Mar 24, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Importance:Major O-Community SDK-Use:Sync T-Enhancement Waiting-For-Reporter Waiting for more information from the reporter before we can proceed
Projects
None yet
Development

No branches or pull requests

2 participants