Search code examples
swift3watchconnectivity

Unable to activate WCSession


I have updated my Xcode project to Swift 3 and because of that I am using Xcode 8 now. In Swift 2 I had no problem setting up a WCSession and sending a message to the watch. Now in Swift 3 I am not able to activate the session. The debugger says: [WC] __28-[WCSession activateSession]_block_invoke informing daemon ready for session state

What does this mean and how to fix this?

PS: In another view controller I am using the exact same code for sending a message but there its works.


Solution

  • Implement the new WCSessionDelegate callback so you can receive any errors / tell when the session activates.

              optional func session(_ session: WCSession,
    activationDidCompleteWithState activationState: WCSessionActivationState,
                             error error: NSError?)
    

    or

    - (void)session:(WCSession *)session
    activationDidCompleteWithState:(WCSessionActivationState)activationState
              error:(NSError *)error