繁体   English   中英

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

[英]WCSession in iOS App using WatchKit 2 Stops App Building

我正在尝试使用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项目中引用。

在ios应用程序的“Build Phases”中使用“Link Binary with Libraries”添加“WatchConnectivity.framework”

确保您已在ios应用程序中导入#import <WatchConnectivity/WatchConnectivity.h>并观看应用程序。 另外在ios app中查看控制器,在watch app中查看InterfaceController符合<WCSessionDelegate>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM