【发布时间】:2019-10-16 09:21:49
【问题描述】:
我目前使用的是 Xcode 11.1,我在网上的任何地方都没有看到这个错误。
我希望能够将数据从 Apple Watch 发送到 iPhone,因此我创建了一个应用程序,它使用从 Apple Watch 到 iPhone 的 sendMessage。
在 ViewController.swift 中,我有
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"])
}
在我的 InterfaceController.swift 中,我有
@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")
}
我从中得到的错误是
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.
但是,iPhone 和 Watch 应用程序都已安装。我什至可以将数据从 iPhone 发送到 Watch 应用程序。我目前将 iPhone 的 UpdateApplicationContext 用于 Watch,将 Watch 的 SendMessage 用于 iPhone。
【问题讨论】:
-
对于以后看到此问题的任何人来说,这似乎是 Apple SDK 的问题。它在 iPhone 和 Apple Watch 上完全可以正常工作,但在运行 iOS 13.1 和 watchOS 6 的 Xcode 11.1 的模拟器上无法正常工作
标签: ios swift iphone apple-watch watchos