iOS 应用程序中的 WCSession 使用 WatchKit 2 停止应用程序构建
WCSession in iOS App using WatchKit 2 Stops App Building
我正在尝试使用 iOS 9.
中新的 WCSession 内容在我的 Watch 应用程序和我的 iPhone 应用程序之间设置通信
将 WCSession 添加到手表扩展中一切顺利,但一旦我尝试将相同的东西添加到我的 phone 目标中,应用程序将不再构建并给我这个错误。
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 项目中添加了对 WatchConnectivity.framework 的引用? iOS 和 watchOS 项目都需要引用它。
在"Build Phases"[=中使用"Link Binary With Libraries"添加"WatchConnectivity.framework" 19=] 在 ios 应用中。
确保您已导入
#import <WatchConnectivity/WatchConnectivity.h>
在 ios 应用和手表应用中。
ios app 中的 view controller 和 watch app 中的 InterfaceController 也符合 <WCSessionDelegate>
我正在尝试使用 iOS 9.
中新的 WCSession 内容在我的 Watch 应用程序和我的 iPhone 应用程序之间设置通信将 WCSession 添加到手表扩展中一切顺利,但一旦我尝试将相同的东西添加到我的 phone 目标中,应用程序将不再构建并给我这个错误。
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 项目中添加了对 WatchConnectivity.framework 的引用? iOS 和 watchOS 项目都需要引用它。
在"Build Phases"[=中使用"Link Binary With Libraries"添加"WatchConnectivity.framework" 19=] 在 ios 应用中。
确保您已导入
#import <WatchConnectivity/WatchConnectivity.h>
在 ios 应用和手表应用中。
ios app 中的 view controller 和 watch app 中的 InterfaceController 也符合 <WCSessionDelegate>