概述:

  • 我正在构建一个非常简单的Apple Watch和iPhone应用程序

  • 我正在使用Xcode中的 Watch 和手机模拟器运行/调试应用程序

  • 我正在使用WatchConnectivity使它们进行通信

  • I cannot activate a WCSession on either the watch or phone simulators although they are paired

在Xcode Devices窗口中,我的 Watch 模拟器和手机模拟器已配对 . 我可以使用WatchKit App方案启动我的 Watch 应用程序(它也会启动手机模拟器,但不会打开手机应用程序) . 然后,我点击手机模拟器上的应用程序图标启动我的移动应用程序 .

移动应用:

  • ViewController 实现 WCSessionDelegate

  • WatchConnectivity会话在 viewDidLoad 方法中激活

观看应用:

  • InterfaceController 实现 WCSessionDelegate

  • WatchConnectivity会话在 willActivate 方法中激活

当我运行WatchKit应用程序时,会记录以下消息:

[WC] WCSession has not been activated

当我通过单击应用程序图标打开移动应用程序时,我收到以下消息:

[WC] WCSession has not been activated
Apple Watch is not paired
[WC] WCSession has not been activated
WatchKit app is not installed on the paired watch

(我添加了日志语句以显示在移动应用程序中检查会话的 isPairedisWatchAppInstalled 的结果)

我的 WCSession 激活码在我的移动应用和观看应用中是相同的:

if ([WCSession isSupported]) {
  WCSession *session = [WCSession defaultSession];
  session.delegate = self;
  [session activateSession];
  // print debugging statements about paired watch, etc.
}

有谁知道为什么WatchConnectivity没有激活 WCSession