Sending Data from Apple Watch to iPhone

Viewed 1354

I am currently using Xcode 11.1, and I have not seen this error anywhere online.

I want to be able to send data from the Apple Watch to the iPhone, so I created an app that uses sendMessage from the Apple Watch to the iPhone.

In ViewController.swift, I have

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        self.wcSession = WCSession.default
        self.wcSession.delegate = self
        self.wcSession.activate()
    }

    func session(_ session: WCSession, didReceiveMessage message: [String : Any], replyHandler: @escaping ([String : Any]) -> Void) {
        print(message["test"])
    }

And in my InterfaceController.swift, I have

    @IBAction func sendToPhone() {
        transferToPhone = ["test": "FROM WATCH"]
        wcSession.sendMessage(transferToPhone, replyHandler: {reply in print("done")}, errorHandler: {error in print(error.localizedDescription)})
        print("sent data over to phone")
    }

The error I get from this is

2019-10-16 17:14:39.345525+0800 sendTest WatchKit Extension[7302:293398] [WC] WCSession iOS app not installed
2019-10-16 17:14:39.348442+0800 sendTest WatchKit Extension[7302:293398] [WC] -[WCSession _onqueue_notifyOfMessageError:messageID:withErrorHandler:] (null) errorHandler: YES with WCErrorDomain:7018
Companion app is not installed.

However, both the iPhone and Watch app are installed. I can even send data from the iPhone to the Watch app. I currently use UpdateApplicationContext for iPhone to the Watch and SendMessage for the Watch to the iPhone.

2 Answers

I was unable to reproduce this in Xcode 11.1 (11A1027). I recommend filing a bug report in Feedback Assistant under Developer Tools → Simulator. Make sure to run xcrun simctl diagnose in Terminal then attach the outputted Simulator logs to the report.

Maybe downloading the latest Xcode 11.2 beta will help as a workaround for now?

Check if "Supports Running Without iOS App Installation" is checked in the WatchKit extension target of the Xcode project. If it is checked, uncheck it.

Related