使用WatchKit 2的iOS应用程序中的WCSession停止应用程序构建

前端之家收集整理的这篇文章主要介绍了使用WatchKit 2的iOS应用程序中的WCSession停止应用程序构建前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用iOS 9中的新WCSession内容在我的Watch App和我的iPhone App之间建立通信.

一切顺利地将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编辑器中没有出现任何错误.它只是不会建立.我正试图在模拟器上运行它.

有任何想法吗?

解决方法

您是否已将WatchConnectivity.framework的引用添加到iOS项目中?它需要在iOS和watchOS项目中引用.
原文链接:https://www.f2er.com/iOS/333162.html

猜你在找的iOS相关文章