Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCSession in iOS App using WatchKit 2 Stops App Building

I'm trying to setup communication between my Watch App and my iPhone App using the new WCSession stuff in iOS 9.

Everything went smoothly adding the WCSession to the watch extension but once I try to add the same thing into my phone target the app will no longer build and gives me this error.

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)

I'm importing it with this:

#import <WatchConnectivity/WatchConnectivity.h>

and then trying to call:

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

There aren't any errors showing up in the Xcode editor. It just won't build. I'm trying to run it on the simulator.

Any ideas?

like image 462
Mark Bridges Avatar asked Aug 18 '15 19:08

Mark Bridges


1 Answers

Have you added a reference to the WatchConnectivity.framework to your iOS project? It needs to be referenced in both the iOS and watchOS projects.

like image 104
lehn0058 Avatar answered Oct 07 '22 11:10

lehn0058