WCSession on iOS App Using WatchKit 2 Stops App Building

I am trying to configure the connection between my monitoring application and my iPhone application using the new WCSession material in iOS 9.

Everything went smoothly, adding a WCSession to the watch extension, but as soon as I try to add the same to my target audience, the application will no longer create and give 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 import it with this:

 #import <WatchConnectivity/WatchConnectivity.h> 

and then try calling:

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

There are no errors in the Xcode editor. He just will not build. I am trying to run it on a simulator.

Any ideas?

+7
ios objective-c ios9 watchkit
source share
2 answers

Have you added a link to WatchConnectivity.framework to your iOS project? It must be specified in both iOS projects and watchOS.

+21
source share

Add “WatchConnectivity.framework” using “Linking binaries to libraries” in “Phase Build” in ios app.

Make sure you import #import <WatchConnectivity/WatchConnectivity.h> in the iOS app and watch. Also, viewing the controller in the ios application and InterfaceController in the watch application corresponds to <WCSessionDelegate>

+2
source share

All Articles