Watch Networking Broken In Xcode 8 Beta 3
Asked Answered
W

0

7

I'm receiving the following error when sending any kind of http request from my WatchKit Extension:

WatchKit Extension[6128:479936] [WC] __33-[WCXPCManager onqueue_reconnect]_block_invoke error reconnecting to daemon due to NSXPCConnectionInterrupted

The message is only attempted to be sent if the session is reachable, which it is at this point. However when I inspect the session object I can see that while reachable is true and the activationState is 2 (WCSessionActivationStateActivated), other properties such as paired and watchAppInstalled are actually false.

In fact, the error is just repeatedly sent multiple times a second while I'm using the app in simulator or device. I'm not sure what's going on but I only started receiving this error when using Xcode 8 Beta 3.

App Delegate:

func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: NSError?) {
    if activationState == WCSessionActivationState.activated {
        NSLog("Activated")
    }

    if activationState == WCSessionActivationState.inactive {
        NSLog("Inactive")
    }

    if activationState == WCSessionActivationState.notActivated {
        NSLog("NotActivated")
    }
}

func sessionDidBecomeInactive(_ session: WCSession) {
    NSLog("sessionDidBecomeInactive")
}

func sessionDidDeactivate(_ session: WCSession) {
    NSLog("sessionDidDeactivate")

    // Begin the activation process for the new Apple Watch.
     WCSession.default().activate()
}

Extension Delegate:

func applicationDidFinishLaunching() {
    // Perform any final initialization of your application.

    if (WCSession.isSupported()) {
        let session = WCSession.default()
        session.delegate = self
        session.activate()
        print("activating")
    }

}

func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: NSError?) {
    // ...
}

Interface controller

if WCSession.defaultSession().reachable { // ... }

How can I solve, or at least work around this issue?

Weisler answered 25/7, 2016 at 17:51 Comment(6)
Beta 3 broke a few things. Have you filed a bug report or posted on the developer forum? Apple monitors their own site, but an Apple engineer might not see it here.Political
I actually don't know what's happening here.. If there have been some changes in watchkit implementation or is it really a bug?Weisler
I'm experiencing this as well. I get back this multiple times per second while attempting to use WCSession communications between my WatchOS and iOS simulators: 2016-07-28 13:00:42.962283 Watch Extension[75009:2496784] [WC] __33-[WCXPCManager onqueue_reconnect]_block_invoke error reconnecting to daemon due to NSXPCConnectionInterruptedAlbanian
Are you experiencing this on actual hardware or just in the simulator?Provided
On b4, the excessive logging has disappeared for me but I still can't establish communication between iOS and watchOS simulators.Weisler
In Xcode 8.1 I get the same error on the simulator, when the WCSession is not reachable and I try to open system settings using UIApplication.shared.open(URL.init(string: UIApplicationOpenSettingsURLString)!, options: [:], completionHandler: nil)Isolecithal

© 2022 - 2024 — McMap. All rights reserved.