realm-swift
realm-swift copied to clipboard
Apple Watch Support for Sync
Goals
Use realm swift in an apple watch app
Expected Results
It should work ?
Actual Results
The sandbox of the apple watch prevents the connection to the realm.
Steps to Reproduce
Create an apple watch app and try to connect to a realm with it on a real device. It works on the simulator but not on a real device.
This is what you will get:
2017-12-10 12:50:24.432939+0100 RealmAWBug WatchKit Extension[373:540595] dnssd_clientstub ConnectToServer: connect()-> No of tries: 1
2017-12-10 12:50:24.560815+0100 RealmAWBug WatchKit Extension[373:540433] Unbalanced calls to begin/end appearance transitions for <PUICNavigationController: 0x162f1a00>.
2017-12-10 12:50:25.438822+0100 RealmAWBug WatchKit Extension[373:540595] dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
2017-12-10 12:50:26.443064+0100 RealmAWBug WatchKit Extension[373:540595] dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
2017-12-10 12:50:27.448825+0100 RealmAWBug WatchKit Extension[373:540595] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:14 Err:-1 Errno:1 Operation not permitted
Sync: Connection[1]: Failed to resolve 'Your address': Host not found (authoritative)
Code Sample
https://github.com/TheNoim/RealmAWBug It dose not really depends on code. But here is an example project This is what I found: https://stackoverflow.com/questions/41219976/apple-watch-kit-wouldnt-fetch-image
Version of Realm and Tooling
ProductName: Mac OS X
ProductVersion: 10.13.1
BuildVersion: 17B1003
/Applications/Xcode.app/Contents/Developer
Xcode 9.2
Build version 9C40b
/usr/local/bin/pod
1.4.0.beta.2
Realm (3.0.2)
RealmSwift (3.0.2)
/bin/bash
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)
carthage not found
(not in use here)
/usr/local/bin/git
git version 2.15.0
Sorry for the delay in responding, @TheNoim.
The only networking that watchOS permits directly from the device is HTTP requests made via NSURLSession
. Realm Platform's synchronization protocol is based on WebSockets and so cannot be implemented on top of NSURLSession
in a way that's compatible with watchOS. This unfortunately means you'll need to limit your use of Realm Platform to your iOS app, and communicate data to your watchOS app via the Watch Connectivity framework.
Is there any way that to tell Realm to not try so that these messages stop showing up in the logs?
@bdash I recently discovered a web socket swift library supporting watch os. It seems like websockets are possible on an apple watch.
Is there any way that to tell Realm to not try so that these messages stop showing up in the logs?
Getting the same error code on my Mac App, and I have the same concern. I guess it is related to realm cloud stuff(not sure), but cannot find a related doc. Can somebody show how to turn it off?
watchOS 6.0 adds support for URLSessionWebSocketTask. It sounds like sync should be possible now.
@realm-support Any idea when we could see sync support on watchOS?
If you have a feature request please add it here: https://feedback.mongodb.com/
I'm getting similar errors with a Mac app. I'm intending to just use it locally and don't want to allow outgoing requests. Is there a way to tell realm to not make the requests?
Any updates on this topic? We would love to use Realm with Sync on our Apple Watch app.
Same as I'd love to see this
Hi @dianaafanador3 👋🏻 , any news regarding this Feature Request? 😄
We don't have a timeline yet - it's somewhat lower in the backlog, but it's still on the plan for this year.
Any updates here? In the meantime, is there any way to establish syncing while we wait for the new feature?
If your watch app is a companion to an iOS app, you can use sync in the iOS app and send visualize the data in the watch app. There's no way to sync from a standalone watch app at this point.
Only interested in standalone sync