【问题标题】:WCSession in iOS App using WatchKit 2 Stops App Building使用 WatchKit 2 的 iOS 应用程序中的 WCSession 停止应用程序构建
【发布时间】:2015-08-18 19:27:45
【问题描述】:

我正在尝试使用 iOS 9 中的新 WCSession 设置我的 Watch 应用和我的 iPhone 应用之间的通信。

将 WCSession 添加到手表扩展程序时一切顺利,但是一旦我尝试将相同的东西添加到我的手机目标中,应用程序将不再构建并给我这个错误。

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_WCSession", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我用这个来导入它:

#import <WatchConnectivity/WatchConnectivity.h>

然后尝试调用:

if ([WCSession isSupported])
{
    self.session = [WCSession defaultSession];
    self.session.delegate = self;
    [self.session activateSession];
}

Xcode 编辑器中没有显示任何错误。它只是不会建立。我正在尝试在模拟器上运行它。

有什么想法吗?

【问题讨论】:

    标签: ios objective-c watchkit ios9


    【解决方案1】:

    您是否在 iOS 项目中添加了对 WatchConnectivity.framework 的引用?它需要在 iOS 和 watchOS 项目中都被引用。

    【讨论】:

    • 在“Build Phases”的“Link Binary With Libraries”下添加“WatchConnectivity.framework”!
    【解决方案2】:

    在ios应用的“构建阶段”中使用“Link Binary With Libraries”添加“WatchConnectivity.framework”

    确保您已导入 #import &lt;WatchConnectivity/WatchConnectivity.h&gt; 在 iOS 应用和手表应用中。 ios app中的view controller和watch app中的InterfaceController也符合&lt;WCSessionDelegate&gt;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多